1 /* File: misc.c */
2
3 /* Purpose: misc code */
4
5 /*
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7 *
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
11 */
12
13 #include "mangband.h"
14
15
16
17
18 /*
19 * Converts stat num into a six-char (right justified) string
20 */
cnv_stat(int val,char * out_val)21 void cnv_stat(int val, char *out_val)
22 {
23 /* Above 18 */
24 if (val > 18)
25 {
26 int bonus = (val - 18);
27
28 if (bonus >= 220)
29 {
30 sprintf(out_val, "18/%3s", "***");
31 }
32 else if (bonus >= 100)
33 {
34 sprintf(out_val, "18/%03d", bonus);
35 }
36 else
37 {
38 sprintf(out_val, " 18/%02d", bonus);
39 }
40 }
41
42 /* From 3 to 18 */
43 else
44 {
45 sprintf(out_val, " %2d", val);
46 }
47 }
48
49
50
51 /*
52 * Modify a stat value by a "modifier", return new value
53 *
54 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
55 * Or even: 18/13, 18/23, 18/33, ..., 18/220
56 *
57 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
58 * Or even: 18/13, 18/03, 18, 17, ..., 3
59 */
modify_stat_value(int value,int amount)60 s16b modify_stat_value(int value, int amount)
61 {
62 int i;
63
64 /* Reward */
65 if (amount > 0)
66 {
67 /* Apply each point */
68 for (i = 0; i < amount; i++)
69 {
70 /* One point at a time */
71 if (value < 18) value++;
72
73 /* Ten "points" at a time */
74 else value += 10;
75 }
76 }
77
78 /* Penalty */
79 else if (amount < 0)
80 {
81 /* Apply each point */
82 for (i = 0; i < (0 - amount); i++)
83 {
84 /* Ten points at a time */
85 if (value >= 18+10) value -= 10;
86
87 /* Hack -- prevent weirdness */
88 else if (value > 18) value = 18;
89
90 /* One point at a time */
91 else if (value > 3) value--;
92 }
93 }
94
95 /* Return new value */
96 return (value);
97 }
98
99
100
101
102
103 /*
104 * Print character stat in given row, column
105 */
prt_stat(player_type * p_ptr,int stat)106 static void prt_stat(player_type *p_ptr, int stat)
107 {
108 int stat_max;
109
110 /* Stat is maxed */
111 if (p_ptr->stat_max[stat] == 18 + 100)
112 {
113 /* Assume top value *is* the max value */
114 stat_max = p_ptr->stat_top[stat];
115 }
116 else
117 {
118 /* Set max to an impossibly large value: */
119 stat_max = p_ptr->stat_top[stat] + 1;
120 }
121
122 send_indication(p_ptr, IN_STAT0 + stat,
123 p_ptr->stat_use[stat], p_ptr->stat_top[stat], stat_max);
124
125 }
126
127
128
129
130 /*
131 * Prints "title", including "wizard" or "winner" as needed.
132 */
prt_title(player_type * p_ptr)133 static void prt_title(player_type *p_ptr)
134 {
135 cptr p = "";
136
137 /* Winner */
138 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
139 {
140 p = (p_ptr->male ? "**KING**" : "**QUEEN**");
141 }
142
143 /* Normal */
144 else
145 {
146 p = c_text + p_ptr->cp_ptr->title[(p_ptr->lev-1)/5];
147 }
148
149 /* Ghost */
150 if (p_ptr->ghost)
151 p = "Ghost";
152 /* Fruit bat */
153 if (p_ptr->fruit_bat)
154 p = "Fruitbat";
155
156 send_indication(p_ptr, IN_TITLE, p);
157 send_ghost(p_ptr);
158 }
159
160
161 /*
162 * Prints level
163 */
prt_level(player_type * p_ptr)164 static void prt_level(player_type *p_ptr)
165 {
166 send_indication(p_ptr, IN_LEVEL, MAX(p_ptr->max_plv, p_ptr->lev), p_ptr->lev);
167 }
168
169
170 /*
171 * Display the experience
172 */
prt_exp(player_type * p_ptr)173 static void prt_exp(player_type *p_ptr)
174 {
175 int adv_exp;
176
177 if (p_ptr->lev >= PY_MAX_LEVEL)
178 adv_exp = 0;
179 else adv_exp = (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L);
180
181 send_indication(p_ptr, IN_EXP, p_ptr->max_exp, p_ptr->exp, adv_exp);
182 }
183
184
185 /*
186 * Prints current gold
187 */
prt_gold(player_type * p_ptr)188 static void prt_gold(player_type *p_ptr)
189 {
190 send_indication(p_ptr, IN_GOLD, p_ptr->au);
191 }
192
193
194
195 /*
196 * Prints current AC
197 */
prt_ac(player_type * p_ptr)198 static void prt_ac(player_type *p_ptr)
199 {
200 send_indication(p_ptr, IN_ARMOR, (p_ptr->dis_ac+p_ptr->dis_to_a), p_ptr->dis_ac, p_ptr->dis_to_a );
201 }
202
203
204 /*
205 * Prints Cur/Max hit points
206 */
prt_hp(player_type * p_ptr)207 static void prt_hp(player_type *p_ptr)
208 {
209 send_indication(p_ptr, IN_HP, p_ptr->chp, p_ptr->mhp );
210 }
211
212 /*
213 * Prints players max/cur spell points
214 */
prt_sp(player_type * p_ptr)215 static void prt_sp(player_type *p_ptr)
216 {
217 /* Do not show mana unless it matters */
218 if (p_ptr->cp_ptr->spell_book)
219 {
220 send_indication(p_ptr, IN_SP, p_ptr->csp, p_ptr->msp);
221 }
222 else
223 {
224 send_indication(p_ptr, IN_SP, 0, 0);
225 }
226 }
227
228
229 /*
230 * Prints depth in stat area
231 */
prt_depth(player_type * p_ptr)232 static void prt_depth(player_type *p_ptr)
233 {
234 send_indication(p_ptr, IN_DEPTH, p_ptr->dun_depth);
235 }
236
237
238 /*
239 * Prints status of hunger
240 */
prt_hunger(player_type * p_ptr)241 static void prt_hunger(player_type *p_ptr)
242 {
243 byte f = 0;
244
245 /* Fainting / Starving */
246 if (p_ptr->food < PY_FOOD_FAINT)
247 {
248 f = 0;
249 }
250
251 /* Weak */
252 else if (p_ptr->food < PY_FOOD_WEAK)
253 {
254 f = 1;
255 }
256
257 /* Hungry */
258 else if (p_ptr->food < PY_FOOD_ALERT)
259 {
260 f = 2;
261 }
262
263 /* Normal */
264 else if (p_ptr->food < PY_FOOD_FULL)
265 {
266 f = 3;
267 }
268
269 /* Full */
270 else if (p_ptr->food < PY_FOOD_MAX)
271 {
272 f = 4;
273 }
274
275 /* Gorged */
276 else
277 {
278 f = 5;
279 }
280
281 send_indication(p_ptr, IN_FOOD, f);
282 }
283
284
285 /*
286 * Prints Blind status
287 */
prt_blind(player_type * p_ptr)288 static void prt_blind(player_type *p_ptr)
289 {
290 if (p_ptr->blind)
291 {
292 send_indication(p_ptr, IN_BLIND, TRUE);
293 }
294 else
295 {
296 send_indication(p_ptr, IN_BLIND, FALSE);
297 }
298 }
299
300
301 /*
302 * Prints Confusion status
303 */
prt_confused(player_type * p_ptr)304 static void prt_confused(player_type *p_ptr)
305 {
306 if (p_ptr->confused)
307 {
308 send_indication(p_ptr, IN_CONFUSED, TRUE);
309 }
310 else
311 {
312 send_indication(p_ptr, IN_CONFUSED, FALSE);
313 }
314 }
315
316
317 /*
318 * Prints Fear status
319 */
prt_afraid(player_type * p_ptr)320 static void prt_afraid(player_type *p_ptr)
321 {
322 if (p_ptr->afraid)
323 {
324 send_indication(p_ptr, IN_AFRAID, TRUE);
325 }
326 else
327 {
328 send_indication(p_ptr, IN_AFRAID, FALSE);
329 }
330 }
331
332
333 /*
334 * Prints Poisoned status
335 */
prt_poisoned(player_type * p_ptr)336 static void prt_poisoned(player_type *p_ptr)
337 {
338 if (p_ptr->poisoned)
339 {
340 send_indication(p_ptr, IN_POISONED, TRUE);
341 }
342 else
343 {
344 send_indication(p_ptr, IN_POISONED, FALSE);
345 }
346 }
347
348 /*
349 * Prints Opposed Elements
350 */
prt_oppose_elements(player_type * p_ptr)351 static void prt_oppose_elements(player_type *p_ptr)
352 {
353 send_indication(p_ptr, IN_OPPOSE, p_ptr->oppose_acid, p_ptr->oppose_elec, p_ptr->oppose_fire, p_ptr->oppose_cold, p_ptr->oppose_pois);
354 }
355
356 /*
357 * Prints Searching, Resting, Paralysis, or 'count' status
358 * Display is always exactly 10 characters wide (see below)
359 *
360 * This function was a major bottleneck when resting, so a lot of
361 * the text formatting code was optimized in place below.
362 */
prt_state(player_type * p_ptr)363 static void prt_state(player_type *p_ptr)
364 {
365 bool p, s, r;
366
367 /* Paralysis */
368 if (p_ptr->paralyzed)
369 {
370 p = TRUE;
371 }
372 else
373 {
374 p = FALSE;
375 }
376
377 /* Searching */
378 if (p_ptr->searching)
379 {
380 s = TRUE;
381 /* Hack -- stealth mode */
382 if (p_ptr->cp_ptr->flags & CF_STEALTH_MODE) s = 2;
383 }
384 else
385 {
386 s = FALSE;
387 }
388
389 /* Resting */
390 if (p_ptr->resting)
391 {
392 r = TRUE;
393 }
394 else
395 {
396 r = FALSE;
397 }
398
399 send_indication(p_ptr, IN_STATE, p, s, r);
400 }
401
402
403 /*
404 * Prints the speed of a character. -CJS-
405 */
prt_speed(player_type * p_ptr)406 static void prt_speed(player_type *p_ptr)
407 {
408 int i = p_ptr->pspeed;
409
410 /* Hack -- Visually "undo" the Search Mode Slowdown */
411 if (p_ptr->searching) i += 10;
412
413 send_indication(p_ptr, IN_SPEED, i - 110 );
414 }
415
prt_study(player_type * p_ptr)416 static void prt_study(player_type *p_ptr)
417 {
418 if (p_ptr->new_spells)
419 {
420 send_indication(p_ptr, IN_STUDY, TRUE);
421 }
422 else
423 {
424 send_indication(p_ptr, IN_STUDY, FALSE);
425 }
426 }
427
428
prt_cut(player_type * p_ptr)429 static void prt_cut(player_type *p_ptr)
430 {
431 int c = p_ptr->cut;
432 int s = 0;
433 if (c > 1000)
434 {
435 s = 7;
436 }
437 else if (c > 200)
438 {
439 s = 6;
440 }
441 else if (c > 100)
442 {
443 s = 5;
444 }
445 else if (c > 50)
446 {
447 s = 4;
448 }
449 else if (c > 25)
450 {
451 s = 3;
452 }
453 else if (c > 10)
454 {
455 s = 2;
456 }
457 else if (c)
458 {
459 s = 1;
460 }
461 else
462 {
463 s = 0;
464 }
465
466 send_indication(p_ptr, IN_CUT, s);
467 }
468
469
470
prt_stun(player_type * p_ptr)471 static void prt_stun(player_type *p_ptr)
472 {
473 int s = p_ptr->stun;
474 int r;
475
476 if (s > 100)
477 {
478 r = 3;
479 }
480 else if (s > 50)
481 {
482 r = 2;
483 }
484 else if (s)
485 {
486 r = 1;
487 }
488 else
489 {
490 r = 0;
491 }
492
493 send_indication(p_ptr, IN_STUN, r);
494 }
495
496 /*
497 * Hack - Display the status line
498 */
cv_put_str(cave_view_type * dest,byte attr,cptr str,int col,int max_col)499 int cv_put_str(cave_view_type* dest, byte attr, cptr str, int col, int max_col)
500 {
501 int i;
502 for (i = 0; i < max_col; i++)
503 {
504 dest[i+col].a = attr;
505 dest[i+col].c = str[i];
506 }
507 return 1;
508 }
c_prt_status_line(player_type * p_ptr,cave_view_type * dest,int len)509 void c_prt_status_line(player_type *p_ptr, cave_view_type *dest, int len)
510 {
511 char buf[32];
512 int col = 0;
513 int i, a;
514
515 /* Clear */
516 for (i = 0; i < len; i++)
517 {
518 dest[i].a = TERM_WHITE;
519 dest[i].c = ' ';
520 }
521
522 /* Hungry */
523 /* Fainting / Starving */
524 if (p_ptr->food < PY_FOOD_FAINT)
525 cv_put_str(dest, TERM_RED, "Weak ", COL_HUNGRY, 6);
526 /* Weak */
527 else if (p_ptr->food < PY_FOOD_WEAK)
528 cv_put_str(dest, TERM_ORANGE, "Weak ", COL_HUNGRY, 6);
529 /* Hungry */
530 else if (p_ptr->food < PY_FOOD_ALERT)
531 cv_put_str(dest, TERM_YELLOW, "Hungry", COL_HUNGRY, 6);
532 /* Normal */
533 else if (p_ptr->food < PY_FOOD_FULL)
534 cv_put_str(dest, TERM_L_GREEN, " ", COL_HUNGRY, 6);
535 /* Full */
536 else if (p_ptr->food < PY_FOOD_MAX)
537 cv_put_str(dest, TERM_L_GREEN, "Full ", COL_HUNGRY, 6);
538 /* Gorged */
539 else
540 cv_put_str(dest, TERM_GREEN, "Gorged", COL_HUNGRY, 6);
541
542 /* Blind */
543 if (p_ptr->blind)
544 cv_put_str(dest, TERM_ORANGE, "Blind", COL_BLIND, 5);
545
546 /* Confused */
547 if (p_ptr->confused)
548 cv_put_str(dest, TERM_ORANGE, "Confused", COL_CONFUSED, 8);
549
550 /* Afraid */
551 if (p_ptr->poisoned)
552 cv_put_str(dest, TERM_ORANGE, "Afraid", COL_AFRAID, 6);
553
554 /* Poisoned */
555 if (p_ptr->poisoned)
556 cv_put_str(dest, TERM_ORANGE, "Poisoned", COL_POISONED, 8);
557
558 /* State */
559 a = TERM_WHITE;
560 if (p_ptr->paralyzed)
561 {
562 a = TERM_RED;
563 strcpy(buf, "Paralyzed!");
564 }
565 else if (p_ptr->searching)
566 {
567 if (!(p_ptr->cp_ptr->flags & CF_STEALTH_MODE))
568 {
569 strcpy(buf, "Searching ");
570 }
571 else
572 {
573 a = TERM_L_DARK;
574 strcpy(buf,"Stlth Mode");
575 }
576 }
577 else if (p_ptr->resting)
578 {
579 strcpy(buf, "Resting ");
580 }
581 else
582 {
583 strcpy(buf, " ");
584 }
585 cv_put_str(dest, a, buf, COL_STATE, 9);
586
587 /* Speed */
588 a = TERM_WHITE;
589 i = p_ptr->pspeed - 110;
590 buf[0] = '\0';
591 if (p_ptr->searching) i += 10;
592 if (i > 0)
593 {
594 a = TERM_L_GREEN;
595 sprintf(buf, "Fast (+%d)", i);
596 }
597 else if (i < 0)
598 {
599 a = TERM_L_UMBER;
600 sprintf(buf, "Slow (%d)", i);
601 }
602 if (!STRZERO(buf))
603 cv_put_str(dest, a, format("%-14s", buf), COL_SPEED, 14);
604
605 /* Study */
606 if (p_ptr->new_spells)
607 cv_put_str(dest, TERM_WHITE, "Study", COL_STUDY, 5);
608
609 /* Depth */
610 buf[0] = '\0';
611 if (!p_ptr->dun_depth)
612 strcpy(buf, "Town");
613 else if (option_p(p_ptr,DEPTH_IN_FEET))
614 sprintf(buf, "%d ft", p_ptr->dun_depth * 50);
615 else
616 sprintf(buf, "Lev %d", p_ptr->dun_depth);
617 cv_put_str(dest, TERM_WHITE, format("%7s", buf), COL_DEPTH, 7);
618
619 /* Temp. resists */
620 col = COL_OPPOSE_ELEMENTS;
621 i = MIN((len - COL_OPPOSE_ELEMENTS) / 5, 5);
622 if (i > 0)
623 {
624 if (p_ptr->oppose_acid)
625 cv_put_str(dest, TERM_SLATE, "Acid ", col, i);
626 col += i;
627
628 if (p_ptr->oppose_elec)
629 cv_put_str(dest, TERM_BLUE, "Elec ", col, i);
630 col += i;
631
632 if (p_ptr->oppose_fire)
633 cv_put_str(dest, TERM_RED, "Fire ", col, i);
634 col += i;
635
636 if (p_ptr->oppose_cold)
637 cv_put_str(dest, TERM_WHITE, "Cold ", col, i);
638 col += i;
639
640 if (p_ptr->oppose_pois)
641 cv_put_str(dest, TERM_GREEN, "Pois ", col, i);
642 col += i; /* Unused */
643 }
644 }
645
646 /*
647 * XXX XXX Obtain the "flags" for the player as if he was an item
648 */
player_flags(player_type * p_ptr,u32b * f1,u32b * f2,u32b * f3)649 void player_flags(player_type *p_ptr, u32b *f1, u32b * f2, u32b *f3)
650 {
651 u32b cf = c_info[p_ptr->pclass].flags;
652 /* Clear */
653 (*f1) = (*f2) = (*f3) = 0L;
654
655 /*
656 Welcome to the bright future!
657 */
658 (*f1) |= p_info[p_ptr->prace].flags1;
659 (*f2) |= p_info[p_ptr->prace].flags2;
660 (*f3) |= p_info[p_ptr->prace].flags3;
661
662 if (cf & CF_BRAVERY_30)
663 {
664 if (p_ptr->lev >= 30) (*f2) |= (TR2_RES_FEAR);
665 }
666
667 /* MAngband-specific: Rogues & Fruit Bats */
668 if ( ((cf & CF_SPEED_BONUS) && !option_p(p_ptr,UNSETH_BONUS)) ||
669 p_ptr->fruit_bat)
670 *f1 |= TR1_SPEED;
671
672 /* MAngband-specific: Ghost */
673 if (p_ptr->ghost) {
674 *f3 |= TR3_SEE_INVIS;
675 *f2 |= TR2_RES_NETHR;
676 *f3 |= TR3_HOLD_LIFE;
677 *f2 |= TR2_RES_FEAR;
678 *f3 |= TR3_FREE_ACT;
679 *f1 |= TR1_INFRA;
680 }
681 }
682
prt_floor_item(player_type * p_ptr)683 static void prt_floor_item(player_type *p_ptr)
684 {
685 int Depth = p_ptr->dun_depth;
686 cave_type *c_ptr;
687 if (cave[Depth]) {
688 c_ptr = &cave[Depth][p_ptr->py][p_ptr->px];
689 floor_item_notify(p_ptr, c_ptr->o_idx, TRUE);
690 }
691 }
692
693 /*
694 * Hack -- see below
695 */
696 static const byte display_player_flag_set[4] =
697 {
698 2,
699 2,
700 3,
701 1
702 };
703
704 /*
705 * Hack -- see below
706 */
707 static const u32b display_player_flag_head[4] =
708 {
709 TR2_RES_ACID,
710 TR2_RES_BLIND,
711 TR3_SLOW_DIGEST,
712 TR1_STEALTH
713 };
714
715
prt_player_equippy(player_type * p_ptr)716 static void prt_player_equippy(player_type *p_ptr)
717 {
718 int i;
719
720 byte a;
721 char c;
722
723 object_type *o_ptr;
724
725 /* Dump equippy chars */
726 for (i = INVEN_WIELD; i < INVEN_TOTAL; ++i)
727 {
728 /* Object */
729 o_ptr = &p_ptr->inventory[i];
730
731 /* Skip empty objects */
732 if (!o_ptr->k_idx) {
733 a = c = 0;
734 } else {
735 /* Get attr/char for display */
736 /*
737 a = k_info[o_ptr->k_idx].d_attr;
738 c = k_info[o_ptr->k_idx].d_char;
739 */
740 a = object_attr_p(p_ptr, o_ptr);
741 c = object_char_p(p_ptr, o_ptr);
742 }
743
744 /* Dump proper character */
745 p_ptr->hist_flags[i-INVEN_WIELD][0].a = a;
746 p_ptr->hist_flags[i-INVEN_WIELD][0].c = c;
747
748 }
749 }
750
751
prt_player_sust_info(player_type * p_ptr)752 static void prt_player_sust_info(player_type *p_ptr)
753 {
754 int i, row, col, stat, boost;
755 object_type *o_ptr;
756 object_kind *k_ptr;
757 ego_item_type *e_ptr;
758 u32b f1, f2, f3, f1_hack = 0;
759 u32b ignore_f2, ignore_f3;
760 byte a;
761 char c;
762
763 ignore_f2 = ignore_f3 = 0L;
764
765 /* Row */
766 row = 3;
767 /* Column */
768 col = 26;
769 /* Header */
770 //c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col);
771 /* Process equipment */
772 for (i = INVEN_WIELD; i < INVEN_TOTAL; ++i)
773 {
774 /* Get the object */
775 o_ptr = &p_ptr->inventory[i];
776 /* And it's base/ego */
777 k_ptr = &k_info[o_ptr->k_idx];
778 e_ptr = &e_info[o_ptr->name2];
779
780 /* Clear flags */
781 f1 = f2 = f3 = 0L;
782 /* Get the "known" flags */
783 object_flags_known(p_ptr, o_ptr, &f1, &f2, &f3);
784 /* Hack -- assume stat modifiers are known .. because they can be calculated */
785 object_flags(o_ptr, &f1, &ignore_f2, &ignore_f3);
786
787 /* Hack -- make a second set of flags for "bpval" items */
788 if (k_ptr->flags1 & TR1_PVAL_MASK)
789 f1_hack = k_ptr->flags1;
790
791 /* Hack -- clear out any pval bonuses that are in the base item */
792 if (o_ptr->name2)
793 f1 &= ~(k_ptr->flags1 & TR1_PVAL_MASK & ~e_ptr->flags1);
794
795 /* Hack -- same for bpval/randarts */
796 if (randart_p(o_ptr))
797 f1_hack &= ~(k_ptr->flags1 & TR1_PVAL_MASK);
798
799 /* Initialize color based of sign of pval. 6 -- total num of stats*/
800 for (stat = 0; stat < A_MAX; stat++)
801 {
802 /* Default */
803 a = TERM_SLATE;
804 c = '.';
805 boost = 0;
806
807 /* Hack -- precalculate boost */
808 if (f1 & (1<<stat)) boost += o_ptr->pval;
809 if (f1_hack & (1<<stat)) boost += o_ptr->bpval;
810
811 /* Boost */
812 if (boost)
813 {
814 /* Default */
815 c = '*';
816 /* Good */
817 if (boost > 0)
818 {
819 /* Good */
820 a = TERM_L_GREEN;
821 /* Label boost */
822 if (boost < 10) c = I2D(boost);
823 }
824 /* Bad */
825 if (boost < 0)
826 {
827 /* Bad */
828 a = TERM_RED;
829 /* Label boost */
830 if (boost > -10) c = I2D(-(boost));
831 }
832 }
833 /* Sustain */
834 if (f2 & (1<<stat))
835 {
836 /* Dark green */
837 a = TERM_GREEN;
838 /* Convert '.' to 's' */
839 if (c == '.') c = 's';
840 }
841 /* Dump proper character */
842 p_ptr->hist_flags[i-INVEN_WIELD][1+stat].a = a;
843 p_ptr->hist_flags[i-INVEN_WIELD][1+stat].c = c;
844 //Term_putch(col, row+stat, a, c);
845 }
846 /* Advance */
847 col++;
848 }
849 /* Player flags */
850 player_flags(p_ptr, &f1, &f2, &f3);
851 /* Check stats */
852 for (stat = 0; stat < A_MAX; ++stat)
853 {
854 /* Default */
855 a = TERM_SLATE;
856 c = '.';
857 /* Sustain */
858 if (f2 & (1<<stat))
859 {
860 /* Dark green "s" */
861 a = TERM_GREEN;
862 c = 's';
863 }
864 /* Dump */
865 p_ptr->hist_flags[12][1+stat].a = a;
866 p_ptr->hist_flags[12][1+stat].c = c;
867 //Term_putch(col, row+stat, a, c);
868 }
869 /* Column */
870 col = 26;
871 /* Footer */
872 //c_put_str(TERM_WHITE, "abcdefghijkl@", row+6, col);
873 /* Equippy */
874 // display_player_equippy(row+7, col);
875 }
876
prt_player_flag_info(player_type * p_ptr)877 static void prt_player_flag_info(player_type *p_ptr)
878 {
879 int x, y, i, n;
880
881 int row, col;
882
883 int realX, realY;
884
885 int set;
886 u32b head;
887 u32b flag;
888 //cptr name;
889
890
891 u32b f[4];
892
893 byte attr = TERM_SLATE;
894 char c = '.';
895
896 object_type *o_ptr;
897
898 realX = 0;
899 realY = 7;
900
901 /* Four columns */
902 for (x = 0; x < 4; x++)
903 {
904 /* Reset */
905 row = 11;
906 col = 20 * x;
907
908 /* Extract set */
909 set = display_player_flag_set[x];
910
911 /* Extract head */
912 head = display_player_flag_head[x];
913
914 /* Header */
915 //c_put_str(TERM_WHITE, "abcdefghijkl@", row++, col+6);
916
917 /* Eight rows */
918 for (y = 0; y < 8; y++)
919 {
920 /* Extract flag */
921 flag = (head << y);
922
923
924 /* Extract name */
925 //name = display_player_flag_names[x][y];
926
927 /* Header */
928 //c_put_str(TERM_WHITE, name, row, col);
929
930 /* Check equipment */
931 for (n = 6, i = INVEN_WIELD; i < INVEN_TOTAL; ++i, ++n)
932 {
933
934 /* Object */
935 o_ptr = &p_ptr->inventory[i];
936
937 /* Default Value */
938 attr = TERM_SLATE;
939 c = '.';
940
941 /* Clear flags */
942 f[1] = f[2] = f[3] = 0L;
943
944 /* Fill in Known flags */
945 if (o_ptr->k_idx) /* don't waste time */
946 {
947 object_flags_known(p_ptr, o_ptr, &f[1], &f[2], &f[3]);
948
949 /* Hack -- additional lite flag */
950 if (i == INVEN_LITE)
951 if (artifact_p(o_ptr) || k_info[o_ptr->k_idx].sval == SV_LITE_DWARVEN || k_info[o_ptr->k_idx].sval == SV_LITE_FEANOR)
952 f[3] |= TR3_LITE;
953 }
954
955 /* Color columns by parity */
956 if (n % 2) attr = TERM_L_WHITE;
957
958 /* Non-existant objects */
959 if (!o_ptr->k_idx) attr = TERM_L_DARK;
960
961 /* Hack -- Check immunities */
962 if ((x == 0) && (y < 4) &&
963 (f[set] & ((TR2_IM_ACID) << y)))
964 {
965 attr = TERM_WHITE;
966 c = '*';
967 //c_put_str(TERM_WHITE, "*", row, col+n);
968 //p_ptr->hist_flags[realX][realY].a = TERM_WHITE;
969 //p_ptr->hist_flags[realX][realY].c = '*';
970 }
971
972 /* Check flags */
973 else if (f[set] & flag)
974 {
975 //c_put_str(TERM_WHITE, "+", row, col+n);
976 attr = TERM_WHITE;
977 c = '+';
978 //p_ptr->hist_flags[realX][realY].a = TERM_WHITE;
979 //p_ptr->hist_flags[realX][realY].c = '+';
980 }
981
982 /* Default */
983 else
984 {
985 //c_put_str(attr, ".", row, col+n);
986 //p_ptr->hist_flags[realX][realY].a = attr;
987 //p_ptr->hist_flags[realX][realY].c = c;
988 }
989
990 p_ptr->hist_flags[realX][realY].a = attr;
991 p_ptr->hist_flags[realX][realY].c = c;
992
993 realX++;
994 }
995
996 /* Clear */
997 f[1] = f[2] = f[3] = 0L;
998
999 /* Player flags */
1000 player_flags(p_ptr, &f[1], &f[2], &f[3]);
1001
1002 /* Default */
1003 //c_put_str(TERM_SLATE, ".", row, col+n);
1004 p_ptr->hist_flags[realX][realY].a = TERM_SLATE;
1005 p_ptr->hist_flags[realX][realY].c = '.';
1006
1007 /* Hack -- Check immunities */
1008 if ((x == 0) && (y < 4) &&
1009 (f[set] & ((TR2_IM_ACID) << y)))
1010 {
1011 //c_put_str(TERM_WHITE, "*", row, col+n);
1012 p_ptr->hist_flags[realX][realY].a = TERM_WHITE;
1013 p_ptr->hist_flags[realX][realY].c = '*';
1014 }
1015
1016 /* Check flags */
1017 else if (f[set] & flag) {
1018 //c_put_str(TERM_WHITE, "+", row, col+n);
1019 p_ptr->hist_flags[realX][realY].a = TERM_WHITE;
1020 p_ptr->hist_flags[realX][realY].c = '+';
1021 }
1022
1023 /* Advance */
1024 row++;
1025
1026 realY++; realX = 0;
1027 }
1028
1029 /* Footer */
1030 //c_put_str(TERM_WHITE, "abcdefghijkl@", row++, col+6);
1031
1032 /* Equippy */
1033 //display_player_equippy(row++, col+6);
1034 }
1035 }
1036
1037
prt_flags(player_type * p_ptr)1038 static void prt_flags(player_type *p_ptr)
1039 {
1040 /* player_type *p_ptr = Players[Ind]; */
1041 int i;
1042
1043 prt_player_equippy(p_ptr);
1044 prt_player_sust_info(p_ptr);
1045 prt_player_flag_info(p_ptr);
1046
1047 for (i = 0; i < MAX_OBJFLAGS_ROWS; i++)
1048 {
1049 send_objflags(p_ptr, i);
1050 }
1051 }
1052
1053
prt_history(player_type * p_ptr)1054 void prt_history(player_type *p_ptr)
1055 {
1056 int i;
1057
1058 for (i = 0; i < 4; i++)
1059 {
1060 send_indication(p_ptr, IN_HISTORY0 + i, p_ptr->history[i]);
1061 }
1062
1063 send_indication(p_ptr, IN_NAME, p_ptr->name);
1064 send_indication(p_ptr, IN_GENDER, p_ptr->male ? "Male" : "Female");
1065 send_indication(p_ptr, IN_RACE, p_name + p_info[p_ptr->prace].name);
1066 send_indication(p_ptr, IN_CLASS, c_name + c_info[p_ptr->pclass].name);
1067 }
prt_misc(player_type * p_ptr)1068 void prt_misc(player_type *p_ptr)
1069 {
1070 send_indication(p_ptr, IN_NAME, p_ptr->name);
1071 send_indication(p_ptr, IN_RACE, p_name + p_info[p_ptr->prace].name);
1072 send_indication(p_ptr, IN_CLASS, c_name + c_info[p_ptr->pclass].name);
1073 }
1074
prt_various(player_type * p_ptr)1075 static void prt_various(player_type *p_ptr)
1076 {
1077 send_indication(p_ptr, IN_VARIOUS, p_ptr->age, p_ptr->ht, p_ptr->wt, p_ptr->sc);
1078 }
1079
prt_plusses(player_type * p_ptr)1080 static void prt_plusses(player_type *p_ptr)
1081 {
1082 int show_tohit = p_ptr->dis_to_h;
1083 int show_todam = p_ptr->dis_to_d;
1084
1085 object_type *o_ptr = &p_ptr->inventory[INVEN_WIELD];
1086
1087 if (object_known_p(p_ptr, o_ptr)) show_tohit += o_ptr->to_h;
1088 if (object_known_p(p_ptr, o_ptr)) show_todam += o_ptr->to_d;
1089
1090 send_indication(p_ptr, IN_PLUSSES, show_tohit, show_todam);
1091 }
1092
prt_skills(player_type * p_ptr)1093 static void prt_skills(player_type *p_ptr)
1094 {
1095 s16b skills[11];
1096 s16b factors[11];
1097 int tmp;
1098 object_type *o_ptr;
1099
1100 /* Fighting skill */
1101 o_ptr = &p_ptr->inventory[INVEN_WIELD];
1102 tmp = p_ptr->to_h + o_ptr->to_h;
1103 skills[0] = p_ptr->skill_thn + (tmp * BTH_PLUS_ADJ);
1104 factors[0] = 12;
1105
1106 /* Shooting skill */
1107 o_ptr = &p_ptr->inventory[INVEN_BOW];
1108 tmp = p_ptr->to_h + o_ptr->to_h;
1109 skills[1] = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
1110 factors[1] = 12;
1111
1112 /* Basic abilities */
1113 skills[2] = p_ptr->skill_sav;
1114 factors[2] = 6;
1115 skills[3] = p_ptr->skill_stl;
1116 factors[3] = 1;
1117 skills[4] = p_ptr->skill_fos;
1118 factors[4] = 6;
1119 skills[5] = p_ptr->skill_srh;
1120 factors[5] = 6;
1121 skills[6] = p_ptr->skill_dis;
1122 factors[6] = 8;
1123 skills[7] = p_ptr->skill_dev;
1124 factors[7] = 6;
1125
1126 /* Number of blows */
1127 skills[8] = p_ptr->num_blow;
1128 skills[9] = p_ptr->num_fire;
1129
1130 /* Infravision */
1131 skills[10] = p_ptr->see_infra;
1132
1133 send_indication(p_ptr, IN_SKILLS,
1134 skills[0], factors[0],
1135 skills[4], factors[4],
1136 skills[1], factors[1],
1137 skills[5], factors[5],
1138 skills[2], factors[2],
1139 skills[6], factors[6],
1140 skills[3], factors[3],
1141 skills[7], factors[7]);
1142
1143 send_indication(p_ptr, IN_SKILLS2, skills[8], skills[9], skills[10]);
1144 }
1145
1146 /*
1147 * Redraw the cursor
1148 *
1149 * This function must simply calculate correct offset for each player
1150 * and update his cursor location
1151 */
cursor_redraw(player_type * p_ptr)1152 static void cursor_redraw(player_type *p_ptr)
1153 {
1154 int vis, x, y = 0;
1155
1156 /* Not tracking */
1157 if (p_ptr->cursor_who == 0)
1158 {
1159 /* Reset the cursor */
1160 vis = 0;
1161 }
1162
1163 /* Tracking a hallucinatory monster */
1164 /* commented: this can't happen as 'looking' doesn't work while hallucinating */
1165 /* else if (p_ptr->image)
1166 {
1167
1168 }
1169 */
1170 /* Tracking a player */
1171 else if (p_ptr->cursor_who < 0)
1172 {
1173 player_type *q_ptr;
1174 /* Make sure we have a valid index */
1175 if (0 - p_ptr->cursor_who > NumPlayers)
1176 {
1177 /* Invalid index -- reset the cursor */
1178 send_cursor(p_ptr, 0,0,0);
1179 /* Reset the index */
1180 p_ptr->cursor_who = 0;
1181 return;
1182 }
1183
1184 q_ptr = Players[0 - p_ptr->cursor_who];
1185
1186 /* Tracking a bad player (?) */
1187 if (!q_ptr)
1188 {
1189 /* Reset the cursor */
1190 vis = 0;
1191 }
1192
1193 /* Tracking an unseen player */
1194 else if (!p_ptr->play_vis[0 - p_ptr->cursor_who])
1195 {
1196 /* Should not be possible */
1197 vis = 0;
1198 }
1199
1200 /* Tracking a visible player */
1201 else
1202 {
1203 vis = 1;
1204 x = q_ptr->px - p_ptr->panel_col_prt;
1205 y = q_ptr->py - p_ptr->panel_row_prt;
1206 }
1207 }
1208
1209 /* Tracking a bad monster (?) */
1210 else if (!m_list[p_ptr->cursor_who].r_idx)
1211 {
1212 /* Reset the cursor */
1213 vis = 0;
1214 }
1215
1216 /* Tracking an unseen monster */
1217 else if (!p_ptr->mon_vis[p_ptr->cursor_who])
1218 {
1219 /* Reset cursor */
1220 vis = 0;
1221 }
1222
1223 /* Tracking a dead monster (???) */
1224 else if (m_list[p_ptr->cursor_who].hp < 0)
1225 {
1226 /* Reset cursor */
1227 vis = 0;
1228 }
1229
1230 /* Tracking a visible monster */
1231 else
1232 {
1233 monster_type *m_ptr = &m_list[p_ptr->cursor_who];
1234
1235 vis = 1;
1236 x = m_ptr->fx - p_ptr->panel_col_prt;
1237 y = m_ptr->fy - p_ptr->panel_row_prt;
1238 }
1239
1240 if (vis == 1)
1241 {
1242 send_cursor(p_ptr, vis, x, y);
1243 }
1244 else
1245 {
1246 send_cursor(p_ptr, 0, 0, 0);
1247
1248 /* Cancel tracking */
1249 p_ptr->cursor_who = 0;
1250 }
1251
1252 }
1253
1254
1255
1256 /*
1257 * Redraw the "monster health bar" -DRS-
1258 * Rather extensive modifications by -BEN-
1259 *
1260 * The "monster health bar" provides visual feedback on the "health"
1261 * of the monster currently being "tracked". There are several ways
1262 * to "track" a monster, including targetting it, attacking it, and
1263 * affecting it (and nobody else) with a ranged attack.
1264 *
1265 * Display the monster health bar (affectionately known as the
1266 * "health-o-meter"). Clear health bar if nothing is being tracked.
1267 * Auto-track current target monster when bored. Note that the
1268 * health-bar stops tracking any monster that "disappears".
1269 */
1270
1271
health_redraw(player_type * p_ptr)1272 static void health_redraw(player_type *p_ptr)
1273 {
1274 #ifdef DRS_SHOW_HEALTH_BAR
1275 byte attr = 0;
1276 int len = 0;
1277
1278 /* Not tracking */
1279 if (p_ptr->health_who == 0)
1280 {
1281 /* Erase the health bar */
1282 }
1283
1284 /* Tracking a hallucinatory monster */
1285 else if (p_ptr->image)
1286 {
1287 /* Indicate that the monster health is "unknown" */
1288 attr = TERM_WHITE;
1289 }
1290
1291 /* Tracking a player */
1292 else if (p_ptr->health_who < 0)
1293 {
1294 player_type *q_ptr;
1295 /* Make sure we have a valid index */
1296 if (0 - p_ptr->health_who > NumPlayers)
1297 {
1298 /* Invalid index -- erase the health bar */
1299 /* Reset the index */
1300 p_ptr->health_who = 0;
1301 }
1302
1303 q_ptr = Players[0 - p_ptr->health_who];
1304
1305 /* Tracking a bad player (?) */
1306 if (!q_ptr)
1307 {
1308 /* Erase the health bar */
1309 }
1310
1311 /* Tracking an unseen player */
1312 else if (!p_ptr->play_vis[0 - p_ptr->health_who])
1313 {
1314 /* Indicate that the player health is "unknown" */
1315 attr = TERM_WHITE;
1316 }
1317
1318 /* Tracking a visible player */
1319 else
1320 {
1321 int pct;
1322
1323 /* Default to almost dead */
1324 attr = TERM_RED;
1325
1326 /* Extract the "percent" of health */
1327 pct = 100L * q_ptr->chp / q_ptr->mhp;
1328
1329 /* Badly wounded */
1330 if (pct >= 10) attr = TERM_L_RED;
1331
1332 /* Wounded */
1333 if (pct >= 25) attr = TERM_ORANGE;
1334
1335 /* Somewhat Wounded */
1336 if (pct >= 60) attr = TERM_YELLOW;
1337
1338 /* Healthy */
1339 if (pct >= 100) attr = TERM_L_GREEN;
1340
1341 /* Afraid */
1342 if (q_ptr->afraid) attr = TERM_VIOLET;
1343
1344 /* Asleep (?) */
1345 if (q_ptr->paralyzed) attr = TERM_BLUE;
1346
1347 /* Convert percent into "health" */
1348 len = (pct < 10) ? 1 : (pct < 90) ? (pct / 10 + 1) : 10;
1349 }
1350 }
1351
1352 /* Tracking a bad monster (?) */
1353 else if (!m_list[p_ptr->health_who].r_idx)
1354 {
1355 /* Erase the health bar */
1356 }
1357
1358 /* Tracking an unseen monster */
1359 else if (!p_ptr->mon_vis[p_ptr->health_who])
1360 {
1361 /* Indicate that the monster health is "unknown" */
1362 attr = TERM_WHITE;
1363 }
1364
1365 /* Tracking a dead monster (???) */
1366 else if (m_list[p_ptr->health_who].hp < 0)
1367 {
1368 /* Indicate that the monster health is "unknown" */
1369 attr = TERM_WHITE;
1370 }
1371
1372 /* Tracking a visible monster */
1373 else
1374 {
1375 int pct;
1376
1377 monster_type *m_ptr = &m_list[p_ptr->health_who];
1378
1379 /* Default to almost dead */
1380 attr = TERM_RED;
1381
1382 /* Extract the "percent" of health */
1383 pct = 100L * m_ptr->hp / m_ptr->maxhp;
1384
1385 /* Badly wounded */
1386 if (pct >= 10) attr = TERM_L_RED;
1387
1388 /* Wounded */
1389 if (pct >= 25) attr = TERM_ORANGE;
1390
1391 /* Somewhat Wounded */
1392 if (pct >= 60) attr = TERM_YELLOW;
1393
1394 /* Healthy */
1395 if (pct >= 100) attr = TERM_L_GREEN;
1396
1397 /* Afraid */
1398 if (m_ptr->monfear) attr = TERM_VIOLET;
1399
1400 /* Asleep */
1401 if (m_ptr->csleep) attr = TERM_BLUE;
1402
1403 /* Convert percent into "health" */
1404 len = (pct < 10) ? 1 : (pct < 90) ? (pct / 10 + 1) : 10;
1405 }
1406
1407 send_indication(p_ptr, IN_MON_HEALTH, (s16b)attr, (s16b)len);
1408 #endif
1409 }
1410
1411
1412
1413 /*
1414 * Hack -- display monsters in sub-windows
1415 */
fix_monlist(player_type * p_ptr)1416 static void fix_monlist(player_type *p_ptr)
1417 {
1418 /* Hack -- do nothing if player is not subscribed */
1419 if (!p_ptr->stream_hgt[STREAM_MONLIST_TEXT]) return;
1420
1421 /* HACK -- Save other player info */
1422 text_out_save(p_ptr);
1423
1424 /* Prepare 'visible monsters' list */
1425 display_monlist(p_ptr);
1426
1427 /* Send it */
1428 send_prepared_info(p_ptr, NTERM_WIN_MONLIST, STREAM_MONLIST_TEXT, 0);
1429
1430 /* HACK -- Load other player info */
1431 text_out_load(p_ptr);
1432
1433 return;
1434 }
1435
1436
1437 /*
1438 * Hack -- display dungeon items in sub-windows
1439 */
fix_itemlist(player_type * p_ptr)1440 static void fix_itemlist(player_type *p_ptr)
1441 {
1442 /* Hack -- do nothing if player is not subscribed */
1443 if (!p_ptr->stream_hgt[STREAM_ITEMLIST_TEXT]) return;
1444
1445 /* HACK -- Save other player info */
1446 text_out_save(p_ptr);
1447
1448 /* Prepare 'visible monsters' list */
1449 display_itemlist(p_ptr);
1450
1451 /* Send it */
1452 send_prepared_info(p_ptr, NTERM_WIN_ITEMLIST, STREAM_ITEMLIST_TEXT, 0);
1453
1454 /* HACK -- Load other player info */
1455 text_out_load(p_ptr);
1456
1457 return;
1458 }
1459
1460
1461 /*
1462 * Hack -- display inventory in sub-windows
1463 */
fix_inven(player_type * p_ptr)1464 static void fix_inven(player_type *p_ptr)
1465 {
1466 /* Resend the inventory */
1467 display_inven(p_ptr);
1468 }
1469
1470
1471
1472 /*
1473 * Hack -- display equipment in sub-windows
1474 */
fix_equip(player_type * p_ptr)1475 static void fix_equip(player_type *p_ptr)
1476 {
1477 /* Resend the equipment */
1478 display_equip(p_ptr);
1479 }
1480
1481
1482 /*
1483 * XXX XXX XXX XXX
1484 */
1485 extern void display_spell_list(void);
1486
1487 /*
1488 * Hack -- display equipment in sub-windows
1489 */
fix_spell(player_type * p_ptr)1490 static void fix_spell(player_type *p_ptr)
1491 {
1492 int i;
1493
1494 /* Ghosts get a different set */
1495 if (p_ptr->ghost)
1496 {
1497 show_ghost_spells(p_ptr);
1498 return;
1499 }
1500
1501 /* Warriors don't need this */
1502 if (!p_ptr->cp_ptr->spell_book)
1503 return;
1504
1505 #if 0
1506 /* Check for blindness and no lite and confusion */
1507 if (p_ptr->blind || no_lite(p_ptr) || p_ptr->confused)
1508 {
1509 return;
1510 }
1511 #endif
1512
1513 /* Scan for appropriate books */
1514 for (i = 0; i < INVEN_WIELD; i++)
1515 {
1516 if (p_ptr->inventory[i].tval == p_ptr->cp_ptr->spell_book)
1517 {
1518 do_cmd_browse(p_ptr, i);
1519 }
1520 }
1521
1522
1523 #if 0
1524 int j;
1525
1526 /* Scan windows */
1527 for (j = 0; j < 8; j++)
1528 {
1529 term *old = Term;
1530
1531 /* No window */
1532 if (!ang_term[j]) continue;
1533
1534 /* No relevant flags */
1535 if (!(window_flag[j] & PW_SPELL)) continue;
1536
1537 /* Activate */
1538 Term_activate(ang_term[j]);
1539
1540 /* Display spell list */
1541 display_spell_list();
1542
1543 /* Fresh */
1544 Term_fresh();
1545
1546 /* Restore */
1547 Term_activate(old);
1548 }
1549 #endif
1550 }
1551
1552
1553 /*
1554 * Hack -- display character in sub-windows
1555 */
fix_player(player_type * p_ptr)1556 static void fix_player(player_type *p_ptr)
1557 {
1558 }
1559
1560
1561
1562 /*
1563 * Hack -- display recent messages in sub-windows
1564 *
1565 * XXX XXX XXX Adjust for width and split messages
1566 */
fix_message(player_type * p_ptr)1567 static void fix_message(player_type *p_ptr)
1568 {
1569 }
1570
1571
1572 /*
1573 * Hack -- display overhead view in sub-windows
1574 *
1575 * Note that the "player" symbol does NOT appear on the map.
1576 */
fix_overhead(player_type * p_ptr)1577 static void fix_overhead(player_type *p_ptr)
1578 {
1579 }
1580
1581
1582 /*
1583 * Hack -- display mini-map view in sub-windows
1584 *
1585 * Note that the "player" symbol does NOT appear on the map.
1586 */
fix_map(player_type * p_ptr)1587 static void fix_map(player_type *p_ptr)
1588 {
1589 display_map(p_ptr, TRUE);
1590 }
1591
1592
1593 /*
1594 * Hack -- display monster recall in sub-windows
1595 */
fix_monster(player_type * p_ptr)1596 static void fix_monster(player_type *p_ptr)
1597 {
1598 /* HACK -- Save other player info */
1599 text_out_save(p_ptr);
1600
1601 do_cmd_monster_desc_aux(p_ptr, p_ptr->monster_race_idx, TRUE);
1602
1603 /* HACK -- Load other player info */
1604 text_out_load(p_ptr);
1605 }
1606
1607
1608 /*
1609 * Calculate number of spells player should have, and forget,
1610 * or remember, spells until that number is properly reflected.
1611 *
1612 * Note that this function induces various "status" messages,
1613 * which must be bypasses until the character is created.
1614 */
calc_spells(player_type * p_ptr)1615 static void calc_spells(player_type *p_ptr)
1616 {
1617 int i, j, k, levels;
1618 int num_allowed, num_known;
1619 int percent_spells;
1620
1621 magic_type *s_ptr;
1622
1623 cptr p = ((p_ptr->cp_ptr->spell_book == TV_PRAYER_BOOK) ? "prayer" : "spell");
1624
1625 int mtype = ((p_ptr->cp_ptr->spell_book == TV_PRAYER_BOOK) ? 1 : 0);
1626
1627 /* Hack -- must be literate */
1628 if (!p_ptr->cp_ptr->spell_book) return;
1629
1630
1631 /* Determine the number of spells allowed */
1632 levels = p_ptr->lev - p_ptr->cp_ptr->spell_first + 1;
1633
1634 /* Hack -- no negative spells */
1635 if (levels < 0) levels = 0;
1636
1637 /* Number of 1/100 spells per level */
1638 percent_spells = adj_mag_study[p_ptr->stat_ind[p_ptr->cp_ptr->spell_stat]];
1639
1640 /* Extract total allowed spells (rounded up) */
1641 num_allowed = (((percent_spells * levels) + 50) / 100);
1642
1643 /* Assume none known */
1644 num_known = 0;
1645
1646 /* Count the number of spells we know */
1647 for (j = 0; j < PY_MAX_SPELLS; j++)
1648 {
1649 /* Count known spells */
1650 if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED)
1651 {
1652 num_known++;
1653 }
1654 }
1655
1656 /* See how many spells we must forget or may learn */
1657 p_ptr->new_spells = num_allowed - num_known;
1658
1659
1660
1661 /* Forget spells which are too hard */
1662 for (i = PY_MAX_SPELLS - 1; i >= 0; i--)
1663 {
1664 /* Access the spell */
1665 j = p_ptr->spell_order[i];
1666
1667 /* Skip non-spells */
1668 if (j >= 99) continue;
1669
1670 /* Get the spell */
1671 s_ptr = &p_ptr->mp_ptr->info[j];
1672
1673 /* Skip spells we are allowed to know */
1674 if (s_ptr->slevel <= p_ptr->lev) continue;
1675
1676 /* Is it known? */
1677 if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED)
1678 {
1679 /* Mark as forgotten */
1680 p_ptr->spell_flags[j] |= PY_SPELL_FORGOTTEN;
1681
1682 /* No longer known */
1683 p_ptr->spell_flags[j] &= ~PY_SPELL_LEARNED;
1684
1685 /* Message */
1686 msg_format(p_ptr, "You have forgotten the %s of %s.", p,
1687 get_spell_name(p_ptr->cp_ptr->spell_book,j));
1688
1689
1690 /* One more can be learned */
1691 p_ptr->new_spells++;
1692 }
1693 }
1694
1695
1696 /* Forget spells if we know too many spells */
1697 for (i = PY_MAX_SPELLS - 1; i >= 0; i--)
1698 {
1699 /* Stop when possible */
1700 if (p_ptr->new_spells >= 0) break;
1701
1702 /* Get the (i+1)th spell learned */
1703 j = p_ptr->spell_order[i];
1704
1705 /* Skip unknown spells */
1706 if (j >= 99) continue;
1707
1708 /* Forget it (if learned) */
1709 if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED)
1710 {
1711 /* Mark as forgotten */
1712 p_ptr->spell_flags[j] |= PY_SPELL_FORGOTTEN;
1713
1714 /* No longer known */
1715 p_ptr->spell_flags[j] &= ~PY_SPELL_LEARNED;
1716
1717 /* Message */
1718 msg_format(p_ptr, "You have forgotten the %s of %s.", p,
1719 spell_names[mtype][j]);
1720
1721
1722 /* One more can be learned */
1723 p_ptr->new_spells++;
1724 }
1725 }
1726
1727
1728 /* Check for spells to remember */
1729 for (i = 0; i < PY_MAX_SPELLS; i++)
1730 {
1731 /* None left to remember */
1732 if (p_ptr->new_spells <= 0) break;
1733
1734 /* Get the next spell we learned */
1735 j = p_ptr->spell_order[i];
1736
1737 /* Skip unknown spells */
1738 if (j >= 99) break;
1739
1740 /* Access the spell */
1741 s_ptr = &p_ptr->mp_ptr->info[j];
1742
1743 /* Skip spells we cannot remember */
1744 if (s_ptr->slevel > p_ptr->lev) continue;
1745
1746 /* First set of spells */
1747 if (p_ptr->spell_flags[j] & PY_SPELL_FORGOTTEN)
1748 {
1749 /* No longer forgotten */
1750 p_ptr->spell_flags[j] &= ~PY_SPELL_FORGOTTEN;
1751
1752 /* Known once more */
1753 p_ptr->spell_flags[j] |= PY_SPELL_LEARNED;
1754
1755 /* Message */
1756 msg_format(p_ptr, "You have remembered the %s of %s.",
1757 p, spell_names[mtype][j]);
1758
1759
1760 /* One less can be learned */
1761 p_ptr->new_spells--;
1762 }
1763 }
1764
1765
1766 /* Assume no spells available */
1767 k = 0;
1768
1769 /* Count spells that can be learned */
1770 for (j = 0; j < PY_MAX_SPELLS; j++)
1771 {
1772 /* Access the spell */
1773 s_ptr = &p_ptr->mp_ptr->info[j];
1774
1775 /* Skip spells we cannot remember */
1776 if (s_ptr->slevel > p_ptr->lev) continue;
1777
1778 /* Skip spells we already know */
1779 if (p_ptr->spell_flags[j] & PY_SPELL_LEARNED)
1780 {
1781 continue;
1782 }
1783
1784 /* Count it */
1785 k++;
1786 }
1787
1788 /* Cannot learn more spells than exist */
1789 if (p_ptr->new_spells > k) p_ptr->new_spells = k;
1790
1791 /* Learn new spells */
1792 if (p_ptr->new_spells && !p_ptr->old_spells)
1793 {
1794 /* Message */
1795 msg_format(p_ptr, "You can learn some new %ss now.", p);
1796
1797 /* Display "study state" later */
1798 p_ptr->redraw |= (PR_STUDY);
1799 }
1800
1801 /* No more spells */
1802 else if (!p_ptr->new_spells && p_ptr->old_spells)
1803 {
1804 /* Display "study state" later */
1805 p_ptr->redraw |= (PR_STUDY);
1806 }
1807
1808 /* Save the new_spells value */
1809 p_ptr->old_spells = p_ptr->new_spells;
1810 }
1811
1812
1813 /*
1814 * Calculate maximum mana. You do not need to know any spells.
1815 * Note that mana is lowered by heavy (or inappropriate) armor.
1816 *
1817 * This function induces status messages.
1818 */
calc_mana(player_type * p_ptr)1819 static void calc_mana(player_type *p_ptr)
1820 {
1821 int new_mana, levels, cur_wgt, max_wgt;
1822
1823 object_type *o_ptr;
1824 u32b f1, f2, f3;
1825
1826
1827 /* Hack -- Must be literate */
1828 if (!p_ptr->cp_ptr->spell_book) return;
1829
1830
1831 /* Extract "effective" player level */
1832 levels = (p_ptr->lev - p_ptr->cp_ptr->spell_first) + 1;
1833
1834 /* Hack -- no negative mana */
1835 if (levels < 0) levels = 0;
1836
1837 /* Extract total mana */
1838 new_mana = adj_mag_mana[p_ptr->stat_ind[p_ptr->cp_ptr->spell_stat]] * levels / 100;
1839
1840 /* Hack -- usually add one mana */
1841 if (new_mana) new_mana++;
1842
1843 /* Get the gloves */
1844 o_ptr = &p_ptr->inventory[INVEN_HANDS];
1845
1846 /* Examine the gloves */
1847 object_flags(o_ptr, &f1, &f2, &f3);
1848
1849 /* Only mages are affected */
1850 if (p_ptr->cp_ptr->spell_book == TV_MAGIC_BOOK)
1851 {
1852 /* Assume player is not encumbered by gloves */
1853 p_ptr->cumber_glove = FALSE;
1854
1855 /* Normal gloves hurt mage-type spells */
1856 if (o_ptr->k_idx &&
1857 !(f3 & TR3_FREE_ACT) &&
1858 !((f1 & TR1_DEX) && (o_ptr->pval > 0)))
1859 {
1860 /* Encumbered */
1861 p_ptr->cumber_glove = TRUE;
1862
1863 /* Reduce mana */
1864 new_mana = (3 * new_mana) / 4;
1865 }
1866 }
1867
1868 /* Assume player not encumbered by armor */
1869 p_ptr->cumber_armor = FALSE;
1870
1871 /* Weigh the armor */
1872 cur_wgt = 0;
1873 cur_wgt += p_ptr->inventory[INVEN_BODY].weight;
1874 cur_wgt += p_ptr->inventory[INVEN_HEAD].weight;
1875 cur_wgt += p_ptr->inventory[INVEN_ARM].weight;
1876 cur_wgt += p_ptr->inventory[INVEN_OUTER].weight;
1877 cur_wgt += p_ptr->inventory[INVEN_HANDS].weight;
1878 cur_wgt += p_ptr->inventory[INVEN_FEET].weight;
1879
1880 /* Determine the weight allowance */
1881 max_wgt = p_ptr->cp_ptr->spell_weight;
1882
1883 /* Heavy armor penalizes mana */
1884 if (((cur_wgt - max_wgt) / 10) > 0)
1885 {
1886 /* Encumbered */
1887 p_ptr->cumber_armor = TRUE;
1888
1889 /* Reduce mana */
1890 new_mana -= ((cur_wgt - max_wgt) / 10);
1891 }
1892
1893
1894 /* Mana can never be negative */
1895 if (new_mana < 0) new_mana = 0;
1896
1897
1898 /* Maximum mana has changed */
1899 if (p_ptr->msp != new_mana)
1900 {
1901 /* Player has no mana now */
1902 if (!new_mana)
1903 {
1904 /* No mana left */
1905 p_ptr->csp = 0;
1906 p_ptr->csp_frac = 0;
1907 }
1908
1909 /* Player had no mana, has some now */
1910 else if (!p_ptr->msp)
1911 {
1912 /* Reset mana */
1913 /* disabled because horribly exploitable!!! */
1914 // p_ptr->csp = new_mana;
1915 p_ptr->csp_frac = 0;
1916 }
1917
1918 /* Player had some mana, adjust current mana */
1919 else
1920 {
1921 s32b value;
1922
1923 /* change current mana proportionately to change of max mana, */
1924 /* divide first to avoid overflow, little loss of accuracy */
1925 value = ((((long)p_ptr->csp << 16) + p_ptr->csp_frac) /
1926 p_ptr->msp * new_mana);
1927
1928 /* Extract mana components */
1929 p_ptr->csp = (value >> 16);
1930 p_ptr->csp_frac = (value & 0xFFFF);
1931 }
1932
1933 /* Save new mana */
1934 p_ptr->msp = new_mana;
1935
1936 /* Display mana later */
1937 p_ptr->redraw |= (PR_MANA);
1938
1939 /* Window stuff */
1940 p_ptr->window |= (PW_PLAYER);
1941 }
1942
1943
1944 /* Take note when "glove state" changes */
1945 if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
1946 {
1947 /* Message */
1948 if (p_ptr->cumber_glove)
1949 {
1950 msg_print(p_ptr, "Your covered hands feel unsuitable for spellcasting.");
1951 }
1952 else
1953 {
1954 msg_print(p_ptr, "Your hands feel more suitable for spellcasting.");
1955 }
1956
1957 /* Save it */
1958 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
1959 }
1960
1961
1962 /* Take note when "armor state" changes */
1963 if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
1964 {
1965 /* Message */
1966 if (p_ptr->cumber_armor)
1967 {
1968 msg_print(p_ptr, "The weight of your armor encumbers your movement.");
1969 }
1970 else
1971 {
1972 msg_print(p_ptr, "You feel able to move more freely.");
1973 }
1974
1975 /* Save it */
1976 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
1977 }
1978 }
1979
1980
1981
1982 /*
1983 * Calculate the players (maximal) hit points
1984 * Adjust current hitpoints if necessary
1985 */
1986
1987 /* An option of giving mages an extra hit point per level has been added,
1988 * to hopefully facilitate them making it down to 1600ish and finding
1989 * Constitution potions. This should probably be changed to stop after level
1990 * 30.
1991 */
1992
calc_hitpoints(player_type * p_ptr)1993 static void calc_hitpoints(player_type *p_ptr)
1994 {
1995 int bonus, mhp;
1996
1997 /* Get "1/100th hitpoint bonus per level" value */
1998 bonus = adj_con_mhp[p_ptr->stat_ind[A_CON]];
1999
2000 /* Calculate hitpoints */
2001 if (p_ptr->fruit_bat) mhp = p_ptr->lev + 2;
2002
2003 else if (p_ptr->ghost) mhp = p_ptr->lev + 2;
2004
2005 else mhp = p_ptr->player_hp[p_ptr->lev-1] + (bonus * p_ptr->lev / 100);
2006
2007 /* Always have at least one hitpoint per level */
2008 if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
2009
2010 /* Option : give (most!) mages a bonus hitpoint / lvl */
2011 if ((p_ptr->cp_ptr->flags & CF_HP_BONUS)
2012 && !option_p(p_ptr,UNSETH_BONUS))
2013 mhp += p_ptr->lev;
2014
2015 /* Factor in the hero / superhero settings */
2016 if (p_ptr->hero) mhp += 10;
2017 if (p_ptr->shero) mhp += 30;
2018
2019 /* New maximum hitpoints */
2020 if (mhp != p_ptr->mhp)
2021 {
2022 s32b value;
2023
2024 /* change current hit points proportionately to change of mhp */
2025 /* divide first to avoid overflow, little loss of accuracy */
2026 value = (((long)p_ptr->chp << 16) + p_ptr->chp_frac) / p_ptr->mhp;
2027 value = value * mhp;
2028 p_ptr->chp = (value >> 16);
2029 p_ptr->chp_frac = (value & 0xFFFF);
2030
2031 /* Save the new max-hitpoints */
2032 p_ptr->mhp = mhp;
2033
2034 /* Check bounds (sometimes chp = mhp + 1) */
2035 if (p_ptr->chp > p_ptr->mhp) p_ptr->chp = p_ptr->mhp;
2036
2037 /* Display hitpoints (later) */
2038 p_ptr->redraw |= (PR_HP);
2039
2040 /* Window stuff */
2041 p_ptr->window |= (PW_PLAYER);
2042 }
2043 }
2044
2045
2046
2047 /*
2048 * Extract and set the current "lite radius"
2049 */
calc_torch(player_type * p_ptr)2050 static void calc_torch(player_type *p_ptr)
2051 {
2052 object_type *o_ptr = &p_ptr->inventory[INVEN_LITE];
2053
2054 /* Base light radius */
2055 p_ptr->cur_lite = p_ptr->lite;
2056
2057 /* Examine actual lites */
2058 if (o_ptr->tval == TV_LITE)
2059 {
2060 /* Torches (with fuel) provide some lite */
2061 if ((o_ptr->sval == SV_LITE_TORCH) && (o_ptr->pval > 0))
2062 {
2063 p_ptr->cur_lite += 1;
2064 }
2065
2066 /* Lanterns (with fuel) provide more lite */
2067 if ((o_ptr->sval == SV_LITE_LANTERN) && (o_ptr->pval > 0))
2068 {
2069 p_ptr->cur_lite += 2;
2070 }
2071
2072 /* Dwarven lanterns provide permanent radius 2 lite */
2073 if (o_ptr->sval == SV_LITE_DWARVEN)
2074 {
2075 p_ptr->cur_lite += 2;
2076 }
2077
2078 /* Feanorian lanterns provide permanent, bright, lite */
2079 if (o_ptr->sval == SV_LITE_FEANOR)
2080 {
2081 p_ptr->cur_lite += 3;
2082 }
2083
2084 /* Artifact Lites provide permanent, bright, lite */
2085 if (artifact_p(o_ptr)) p_ptr->cur_lite += 3;
2086 }
2087
2088 /* Reduce lite when running if requested */
2089 if (p_ptr->running && option_p(p_ptr,VIEW_REDUCE_LITE))
2090 {
2091 /* Reduce the lite radius if needed */
2092 if (p_ptr->cur_lite > 1) p_ptr->cur_lite = 1;
2093 }
2094
2095 /* Notice changes in the "lite radius" */
2096 if (p_ptr->old_lite != p_ptr->cur_lite)
2097 {
2098 /* Hack - Dungeon Master keeps his light */
2099 if (dm_flag_p(p_ptr,KEEP_LITE))
2100 {
2101 p_ptr->cur_lite = p_ptr->old_lite;
2102 return;
2103 }
2104
2105 /* Update the lite */
2106 p_ptr->update |= (PU_LITE);
2107
2108 /* Update the monsters */
2109 p_ptr->update |= (PU_MONSTERS);
2110
2111 /* Remember the old lite */
2112 p_ptr->old_lite = p_ptr->cur_lite;
2113 }
2114 }
2115
2116
2117
2118 /*
2119 * Computes current weight limit.
2120 */
weight_limit(player_type * p_ptr)2121 static int weight_limit(player_type *p_ptr)
2122 {
2123 int i;
2124
2125 /* Weight limit based only on strength */
2126 i = adj_str_wgt[p_ptr->stat_ind[A_STR]] * 100;
2127
2128 /* Return the result */
2129 return (i);
2130 }
2131
2132
2133 /*
2134 * Calculate the players current "state", taking into account
2135 * not only race/class intrinsics, but also objects being worn
2136 * and temporary spell effects.
2137 *
2138 * See also calc_mana() and calc_hitpoints().
2139 *
2140 * Take note of the new "speed code", in particular, a very strong
2141 * player will start slowing down as soon as he reaches 150 pounds,
2142 * but not until he reaches 450 pounds will he be half as fast as
2143 * a normal kobold. This both hurts and helps the player, hurts
2144 * because in the old days a player could just avoid 300 pounds,
2145 * and helps because now carrying 300 pounds is not very painful.
2146 *
2147 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
2148 * damage, since that would affect non-combat things. These values
2149 * are actually added in later, at the appropriate place.
2150 *
2151 * This function induces various "status" messages.
2152 */
calc_bonuses(player_type * p_ptr)2153 static void calc_bonuses(player_type *p_ptr)
2154 {
2155 int i, j, hold;
2156
2157 int old_speed;
2158
2159 u32b old_telepathy;
2160 int old_see_inv;
2161
2162 int old_dis_ac;
2163 int old_dis_to_a;
2164
2165 int old_dis_to_h;
2166 int old_dis_to_d;
2167
2168 int extra_blows;
2169 int extra_shots;
2170
2171 object_type *o_ptr;
2172 object_kind *k_ptr;
2173 ego_item_type *e_ptr;
2174
2175 u32b f1, f2, f3;
2176
2177 /*** Memorize ***/
2178
2179 /* Save the old speed */
2180 old_speed = p_ptr->pspeed;
2181
2182 /* Save the old vision stuff */
2183 old_telepathy = p_ptr->telepathy;
2184 old_see_inv = p_ptr->see_inv;
2185
2186 /* Save the old armor class */
2187 old_dis_ac = p_ptr->dis_ac;
2188 old_dis_to_a = p_ptr->dis_to_a;
2189
2190 /* Save the old hit/damage bonuses */
2191 old_dis_to_h = p_ptr->dis_to_h;
2192 old_dis_to_d = p_ptr->dis_to_d;
2193
2194 /*** Reset ***/
2195
2196 /* Start with "normal" speed */
2197 p_ptr->pspeed = 110;
2198
2199 /* MAngband-specific: Bats get +10 speed ... they need it! */
2200 if (p_ptr->fruit_bat) p_ptr->pspeed += 10;
2201
2202 /* Start with a single blow per turn */
2203 p_ptr->num_blow = 1;
2204
2205 /* Start with a single shot per turn */
2206 p_ptr->num_fire = 1;
2207
2208 /* Reset the "xtra" tval */
2209 p_ptr->tval_xtra = 0;
2210
2211 /* Reset the "ammo" tval */
2212 p_ptr->tval_ammo = 0;
2213
2214 /* Clear extra blows/shots */
2215 extra_blows = extra_shots = 0;
2216
2217 /* Clear the stat modifiers */
2218 for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0;
2219
2220 /* Clear the Displayed/Real armor class */
2221 p_ptr->dis_ac = p_ptr->ac = 0;
2222
2223 /* Clear the Displayed/Real Bonuses */
2224 p_ptr->dis_to_h = p_ptr->to_h = 0;
2225 p_ptr->dis_to_d = p_ptr->to_d = 0;
2226 p_ptr->dis_to_a = p_ptr->to_a = 0;
2227
2228 /* Clear all the flags */
2229 p_ptr->aggravate = FALSE;
2230 p_ptr->teleport = FALSE;
2231 p_ptr->exp_drain = FALSE;
2232 p_ptr->bless_blade = FALSE;
2233 p_ptr->xtra_might = FALSE;
2234 p_ptr->impact = FALSE;
2235 p_ptr->see_inv = FALSE;
2236 p_ptr->free_act = FALSE;
2237 p_ptr->slow_digest = FALSE;
2238 p_ptr->regenerate = FALSE;
2239 p_ptr->feather_fall = FALSE;
2240 p_ptr->hold_life = FALSE;
2241 p_ptr->telepathy = 0;
2242 p_ptr->lite = FALSE;
2243 p_ptr->sustain_str = FALSE;
2244 p_ptr->sustain_int = FALSE;
2245 p_ptr->sustain_wis = FALSE;
2246 p_ptr->sustain_con = FALSE;
2247 p_ptr->sustain_dex = FALSE;
2248 p_ptr->sustain_chr = FALSE;
2249 p_ptr->resist_acid = FALSE;
2250 p_ptr->resist_elec = FALSE;
2251 p_ptr->resist_fire = FALSE;
2252 p_ptr->resist_cold = FALSE;
2253 p_ptr->resist_pois = FALSE;
2254 p_ptr->resist_conf = FALSE;
2255 p_ptr->resist_sound = FALSE;
2256 p_ptr->resist_lite = FALSE;
2257 p_ptr->resist_dark = FALSE;
2258 p_ptr->resist_chaos = FALSE;
2259 p_ptr->resist_disen = FALSE;
2260 p_ptr->resist_shard = FALSE;
2261 p_ptr->resist_nexus = FALSE;
2262 p_ptr->resist_blind = FALSE;
2263 p_ptr->resist_neth = FALSE;
2264 p_ptr->resist_fear = FALSE;
2265 p_ptr->immune_acid = FALSE;
2266 p_ptr->immune_elec = FALSE;
2267 p_ptr->immune_fire = FALSE;
2268 p_ptr->immune_cold = FALSE;
2269
2270
2271 /*** Extract race/class info ***/
2272
2273 /* Base infravision (purely racial) */
2274 p_ptr->see_infra = p_ptr->rp_ptr->infra;
2275
2276 /* Base skill -- disarming */
2277 p_ptr->skill_dis = p_ptr->rp_ptr->r_dis + p_ptr->cp_ptr->c_dis;
2278
2279 /* Base skill -- magic devices */
2280 p_ptr->skill_dev = p_ptr->rp_ptr->r_dev + p_ptr->cp_ptr->c_dev;
2281
2282 /* Base skill -- saving throw */
2283 p_ptr->skill_sav = p_ptr->rp_ptr->r_sav + p_ptr->cp_ptr->c_sav;
2284
2285 /* Base skill -- stealth */
2286 p_ptr->skill_stl = p_ptr->rp_ptr->r_stl + p_ptr->cp_ptr->c_stl;
2287
2288 /* Base skill -- searching ability */
2289 p_ptr->skill_srh = p_ptr->rp_ptr->r_srh + p_ptr->cp_ptr->c_srh;
2290
2291 /* Base skill -- searching frequency */
2292 p_ptr->skill_fos = p_ptr->rp_ptr->r_fos + p_ptr->cp_ptr->c_fos;
2293
2294 /* Base skill -- combat (normal) */
2295 p_ptr->skill_thn = p_ptr->rp_ptr->r_thn + p_ptr->cp_ptr->c_thn;
2296
2297 /* Base skill -- combat (shooting) */
2298 p_ptr->skill_thb = p_ptr->rp_ptr->r_thb + p_ptr->cp_ptr->c_thb;
2299
2300 /* Base skill -- combat (throwing) */
2301 p_ptr->skill_tht = p_ptr->rp_ptr->r_thb + p_ptr->cp_ptr->c_thb;
2302
2303 /* Base skill -- digging */
2304 p_ptr->skill_dig = 0;
2305
2306
2307 /*** Analyze player ***/
2308
2309 /* Extract the player flags */
2310 player_flags(p_ptr, &f1, &f2, &f3);
2311
2312 /* Good flags */
2313 if (f3 & (TR3_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
2314 if (f3 & (TR3_FEATHER)) p_ptr->feather_fall = TRUE;
2315 if (f3 & (TR3_LITE)) p_ptr->lite = TRUE;
2316 if (f3 & (TR3_REGEN)) p_ptr->regenerate = TRUE;
2317 if (f3 & (TR3_TELEPATHY)) p_ptr->telepathy = TRUE;
2318 if (f3 & (TR3_SEE_INVIS)) p_ptr->see_inv = TRUE;
2319 if (f3 & (TR3_FREE_ACT)) p_ptr->free_act = TRUE;
2320 if (f3 & (TR3_HOLD_LIFE)) p_ptr->hold_life = TRUE;
2321
2322 /* Weird flags */
2323 if (f3 & (TR3_BLESSED)) p_ptr->bless_blade = TRUE;
2324
2325 /* Bad flags */
2326 if (f3 & (TR3_IMPACT)) p_ptr->impact = TRUE;
2327 if (f3 & (TR3_AGGRAVATE)) p_ptr->aggravate = TRUE;
2328 if (f3 & (TR3_TELEPORT)) p_ptr->teleport = TRUE;
2329 if (f3 & (TR3_DRAIN_EXP)) p_ptr->exp_drain = TRUE;
2330
2331 /* Immunity flags */
2332 if (f2 & (TR2_IM_FIRE)) p_ptr->immune_fire = TRUE;
2333 if (f2 & (TR2_IM_ACID)) p_ptr->immune_acid = TRUE;
2334 if (f2 & (TR2_IM_COLD)) p_ptr->immune_cold = TRUE;
2335 if (f2 & (TR2_IM_ELEC)) p_ptr->immune_elec = TRUE;
2336
2337 /* Resistance flags */
2338 if (f2 & (TR2_RES_ACID)) p_ptr->resist_acid = TRUE;
2339 if (f2 & (TR2_RES_ELEC)) p_ptr->resist_elec = TRUE;
2340 if (f2 & (TR2_RES_FIRE)) p_ptr->resist_fire = TRUE;
2341 if (f2 & (TR2_RES_COLD)) p_ptr->resist_cold = TRUE;
2342 if (f2 & (TR2_RES_POIS)) p_ptr->resist_pois = TRUE;
2343 if (f2 & (TR2_RES_FEAR)) p_ptr->resist_fear = TRUE;
2344 if (f2 & (TR2_RES_LITE)) p_ptr->resist_lite = TRUE;
2345 if (f2 & (TR2_RES_DARK)) p_ptr->resist_dark = TRUE;
2346 if (f2 & (TR2_RES_BLIND)) p_ptr->resist_blind = TRUE;
2347 if (f2 & (TR2_RES_CONFU)) p_ptr->resist_conf = TRUE;
2348 if (f2 & (TR2_RES_SOUND)) p_ptr->resist_sound = TRUE;
2349 if (f2 & (TR2_RES_SHARD)) p_ptr->resist_shard = TRUE;
2350 if (f2 & (TR2_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
2351 if (f2 & (TR2_RES_NETHR)) p_ptr->resist_neth = TRUE;
2352 if (f2 & (TR2_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
2353 if (f2 & (TR2_RES_DISEN)) p_ptr->resist_disen = TRUE;
2354
2355 /* Sustain flags */
2356 if (f2 & (TR2_SUST_STR)) p_ptr->sustain_str = TRUE;
2357 if (f2 & (TR2_SUST_INT)) p_ptr->sustain_int = TRUE;
2358 if (f2 & (TR2_SUST_WIS)) p_ptr->sustain_wis = TRUE;
2359 if (f2 & (TR2_SUST_DEX)) p_ptr->sustain_dex = TRUE;
2360 if (f2 & (TR2_SUST_CON)) p_ptr->sustain_con = TRUE;
2361 if (f2 & (TR2_SUST_CHR)) p_ptr->sustain_chr = TRUE;
2362
2363 /* Hack -- apply racial/class stat maxes */
2364 if (p_ptr->maximize)
2365 {
2366 /* Apply the racial modifiers */
2367 for (i = 0; i < A_MAX; i++)
2368 {
2369 /* Modify the stats for "race" */
2370 p_ptr->stat_add[i] += (p_ptr->rp_ptr->r_adj[i] + p_ptr->cp_ptr->c_adj[i]);
2371 }
2372 }
2373
2374
2375 /* Option : give (most!) rogues a bonus speed point on level 5,20,35,50 -APD- */
2376 if ((p_ptr->cp_ptr->flags & CF_SPEED_BONUS) && !option_p(p_ptr,UNSETH_BONUS))
2377 {
2378 if (p_ptr->lev >= 5)
2379 {
2380 p_ptr->pspeed += (((p_ptr->lev-5)/15)+1);
2381 }
2382 }
2383
2384 /* Hack -- the dungeon master gets +50 speed. */
2385 if (is_dm_p(p_ptr))
2386 {
2387 p_ptr->pspeed += 50;
2388 p_ptr->telepathy = TR3_TELEPATHY;
2389 }
2390
2391
2392 /*** Analyze equipment ***/
2393
2394 /* Scan the usable inventory */
2395 for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
2396 {
2397 o_ptr = &p_ptr->inventory[i];
2398 k_ptr = &k_info[o_ptr->k_idx];
2399 e_ptr = &e_info[o_ptr->name2];
2400
2401 /* Skip missing items */
2402 if (!o_ptr->k_idx) continue;
2403
2404 /* Extract the item flags */
2405 object_flags(o_ptr, &f1, &f2, &f3);
2406
2407 /* Hack -- first add any "base bonuses" of the item. A new
2408 * feature in MAngband 0.7.0 is that the magnitude of the
2409 * base bonuses is stored in bpval instead of pval, making the
2410 * magnitude of "base bonuses" and "ego bonuses" independent
2411 * from each other.
2412 * An example of an item that uses this independency is an
2413 * Orcish Shield of the Avari that gives +1 to STR and +3 to
2414 * CON. (base bonus from the shield +1 STR,CON, ego bonus from
2415 * the Avari +2 CON).
2416 * Of course, the proper fix would be to redesign the object
2417 * type so that each of the ego bonuses has its own independent
2418 * parameter.
2419 */
2420 /* NOTE: Randarts totally ignore "bpval"! */
2421 /* If we have any base bonuses to add, add them */
2422 if ((k_ptr->flags1 & TR1_PVAL_MASK) && !randart_p(o_ptr))
2423 {
2424 /* Affect stats */
2425 if (k_ptr->flags1 & TR1_STR) p_ptr->stat_add[A_STR] += o_ptr->bpval;
2426 if (k_ptr->flags1 & TR1_INT) p_ptr->stat_add[A_INT] += o_ptr->bpval;
2427 if (k_ptr->flags1 & TR1_WIS) p_ptr->stat_add[A_WIS] += o_ptr->bpval;
2428 if (k_ptr->flags1 & TR1_DEX) p_ptr->stat_add[A_DEX] += o_ptr->bpval;
2429 if (k_ptr->flags1 & TR1_CON) p_ptr->stat_add[A_CON] += o_ptr->bpval;
2430 if (k_ptr->flags1 & TR1_CHR) p_ptr->stat_add[A_CHR] += o_ptr->bpval;
2431
2432 /* Affect stealth */
2433 if (k_ptr->flags1 & TR1_STEALTH) p_ptr->skill_stl += o_ptr->bpval;
2434
2435 /* Affect searching ability (factor of five) */
2436 if (k_ptr->flags1 & TR1_SEARCH) p_ptr->skill_srh += (o_ptr->bpval * 5);
2437
2438 /* Affect searching frequency (factor of five) */
2439 if (k_ptr->flags1 & TR1_SEARCH) p_ptr->skill_fos += (o_ptr->bpval * 5);
2440
2441 /* Affect infravision */
2442 if (k_ptr->flags1 & TR1_INFRA) p_ptr->see_infra += o_ptr->bpval;
2443
2444 /* Affect digging (factor of 20) */
2445 if (k_ptr->flags1 & TR1_TUNNEL) p_ptr->skill_dig += (o_ptr->bpval * 20);
2446
2447 /* Affect speed */
2448 if (k_ptr->flags1 & TR1_SPEED) p_ptr->pspeed += o_ptr->bpval;
2449
2450 /* Affect blows */
2451 if (k_ptr->flags1 & TR1_BLOWS) extra_blows += o_ptr->bpval;
2452 }
2453
2454 /* Next, add our ego bonuses */
2455 /* Hack -- clear out any pval bonuses that are in the base item
2456 * bonus but not the ego bonus so we don't add them twice.
2457 */
2458 if (o_ptr->name2)
2459 {
2460 f1 &= ~(k_ptr->flags1 & TR1_PVAL_MASK & ~e_ptr->flags1);
2461 }
2462
2463
2464 /* Affect stats */
2465 if (f1 & TR1_STR) p_ptr->stat_add[A_STR] += o_ptr->pval;
2466 if (f1 & TR1_INT) p_ptr->stat_add[A_INT] += o_ptr->pval;
2467 if (f1 & TR1_WIS) p_ptr->stat_add[A_WIS] += o_ptr->pval;
2468 if (f1 & TR1_DEX) p_ptr->stat_add[A_DEX] += o_ptr->pval;
2469 if (f1 & TR1_CON) p_ptr->stat_add[A_CON] += o_ptr->pval;
2470 if (f1 & TR1_CHR) p_ptr->stat_add[A_CHR] += o_ptr->pval;
2471
2472 /* Affect stealth */
2473 if (f1 & TR1_STEALTH) p_ptr->skill_stl += o_ptr->pval;
2474
2475 /* Affect searching ability (factor of five) */
2476 if (f1 & TR1_SEARCH) p_ptr->skill_srh += (o_ptr->pval * 5);
2477
2478 /* Affect searching frequency (factor of five) */
2479 if (f1 & TR1_SEARCH) p_ptr->skill_fos += (o_ptr->pval * 5);
2480
2481 /* Affect infravision */
2482 if (f1 & TR1_INFRA) p_ptr->see_infra += o_ptr->pval;
2483
2484 /* Affect digging (factor of 20) */
2485 if (f1 & TR1_TUNNEL) p_ptr->skill_dig += (o_ptr->pval * 20);
2486
2487 /* Affect speed */
2488 if (f1 & TR1_SPEED) p_ptr->pspeed += o_ptr->pval;
2489
2490 /* Affect blows */
2491 if (f1 & TR1_BLOWS) extra_blows += o_ptr->pval;
2492
2493 /* Hack -- cause earthquakes */
2494 if (f3 & TR3_IMPACT) p_ptr->impact = TRUE;
2495
2496 /* Boost shots */
2497 if (f1 & TR1_SHOTS) extra_shots++;
2498
2499 /* Various flags */
2500 if (f3 & TR3_AGGRAVATE) p_ptr->aggravate = TRUE;
2501 if (f3 & TR3_TELEPORT) p_ptr->teleport = TRUE;
2502 if (f3 & TR3_DRAIN_EXP) p_ptr->exp_drain = TRUE;
2503 if (f3 & TR3_BLESSED) p_ptr->bless_blade = TRUE;
2504 if (f1 & TR1_MIGHT) p_ptr->xtra_might = TRUE;
2505 if (f3 & TR3_SLOW_DIGEST) p_ptr->slow_digest = TRUE;
2506 if (f3 & TR3_REGEN) p_ptr->regenerate = TRUE;
2507 if (f3 & TR3_LITE) p_ptr->lite += 1;
2508 if (f3 & TR3_SEE_INVIS) p_ptr->see_inv = TRUE;
2509 if (f3 & TR3_FEATHER) p_ptr->feather_fall = TRUE;
2510 if (f2 & TR2_RES_FEAR) p_ptr->resist_fear = TRUE;
2511 if (f3 & TR3_FREE_ACT) p_ptr->free_act = TRUE;
2512 if (f3 & TR3_HOLD_LIFE) p_ptr->hold_life = TRUE;
2513
2514 /* telepathy */
2515 if (f3 & TR3_TELEPATHY)
2516 p_ptr->telepathy = TR3_TELEPATHY;
2517 else if (p_ptr->telepathy != TR3_TELEPATHY)
2518 p_ptr->telepathy |= f3;
2519
2520 /* Immunity flags */
2521 if (f2 & TR2_IM_FIRE) p_ptr->immune_fire = TRUE;
2522 if (f2 & TR2_IM_ACID) p_ptr->immune_acid = TRUE;
2523 if (f2 & TR2_IM_COLD) p_ptr->immune_cold = TRUE;
2524 if (f2 & TR2_IM_ELEC) p_ptr->immune_elec = TRUE;
2525
2526 /* Resistance flags */
2527 if (f2 & TR2_RES_ACID) p_ptr->resist_acid = TRUE;
2528 if (f2 & TR2_RES_ELEC) p_ptr->resist_elec = TRUE;
2529 if (f2 & TR2_RES_FIRE) p_ptr->resist_fire = TRUE;
2530 if (f2 & TR2_RES_COLD) p_ptr->resist_cold = TRUE;
2531 if (f2 & TR2_RES_POIS) p_ptr->resist_pois = TRUE;
2532 if (f2 & TR2_RES_CONFU) p_ptr->resist_conf = TRUE;
2533 if (f2 & TR2_RES_SOUND) p_ptr->resist_sound = TRUE;
2534 if (f2 & TR2_RES_LITE) p_ptr->resist_lite = TRUE;
2535 if (f2 & TR2_RES_DARK) p_ptr->resist_dark = TRUE;
2536 if (f2 & TR2_RES_CHAOS) p_ptr->resist_chaos = TRUE;
2537 if (f2 & TR2_RES_DISEN) p_ptr->resist_disen = TRUE;
2538 if (f2 & TR2_RES_SHARD) p_ptr->resist_shard = TRUE;
2539 if (f2 & TR2_RES_NEXUS) p_ptr->resist_nexus = TRUE;
2540 if (f2 & TR2_RES_BLIND) p_ptr->resist_blind = TRUE;
2541 if (f2 & TR2_RES_NETHR) p_ptr->resist_neth = TRUE;
2542
2543 /* Sustain flags */
2544 if (f2 & TR2_SUST_STR) p_ptr->sustain_str = TRUE;
2545 if (f2 & TR2_SUST_INT) p_ptr->sustain_int = TRUE;
2546 if (f2 & TR2_SUST_WIS) p_ptr->sustain_wis = TRUE;
2547 if (f2 & TR2_SUST_DEX) p_ptr->sustain_dex = TRUE;
2548 if (f2 & TR2_SUST_CON) p_ptr->sustain_con = TRUE;
2549 if (f2 & TR2_SUST_CHR) p_ptr->sustain_chr = TRUE;
2550
2551 /* Modify the base armor class */
2552 p_ptr->ac += o_ptr->ac;
2553
2554 /* The base armor class is always known */
2555 p_ptr->dis_ac += o_ptr->ac;
2556
2557 /* Apply the bonuses to armor class */
2558 p_ptr->to_a += o_ptr->to_a;
2559
2560 /* Apply the mental bonuses to armor class, if known */
2561 if (object_known_p(p_ptr, o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
2562
2563 /* Hack -- do not apply "weapon" bonuses */
2564 if (i == INVEN_WIELD) continue;
2565
2566 /* Hack -- do not apply "bow" bonuses */
2567 if (i == INVEN_BOW) continue;
2568
2569 /* Apply the bonuses to hit/damage */
2570 p_ptr->to_h += o_ptr->to_h;
2571 p_ptr->to_d += o_ptr->to_d;
2572
2573 /* Apply the mental bonuses tp hit/damage, if known */
2574 if (object_known_p(p_ptr, o_ptr)) p_ptr->dis_to_h += o_ptr->to_h;
2575 if (object_known_p(p_ptr, o_ptr)) p_ptr->dis_to_d += o_ptr->to_d;
2576 }
2577
2578
2579 /*** Handle stats ***/
2580
2581 /* Calculate stats */
2582 for (i = 0; i < A_MAX; i++)
2583 {
2584 int top, use, ind;
2585
2586
2587 /* Extract the new "stat_use" value for the stat */
2588 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
2589
2590 /* Notice changes */
2591 if (p_ptr->stat_top[i] != top)
2592 {
2593 /* Save the new value */
2594 p_ptr->stat_top[i] = top;
2595
2596 /* Redisplay the stats later */
2597 p_ptr->redraw |= (PR_STATS);
2598
2599 /* Window stuff */
2600 p_ptr->window |= (PW_PLAYER);
2601 }
2602
2603
2604 /* Extract the new "stat_use" value for the stat */
2605 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
2606
2607 /* Notice changes */
2608 if (p_ptr->stat_use[i] != use)
2609 {
2610 /* Save the new value */
2611 p_ptr->stat_use[i] = use;
2612
2613 /* Redisplay the stats later */
2614 p_ptr->redraw |= (PR_STATS);
2615
2616 /* Window stuff */
2617 p_ptr->window |= (PW_PLAYER);
2618 }
2619
2620
2621 /* Values: 3, 4, ..., 17 */
2622 if (use <= 18) ind = (use - 3);
2623
2624 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
2625 else if (use <= 18+219) ind = (15 + (use - 18) / 10);
2626
2627 /* Range: 18/220+ */
2628 else ind = (37);
2629
2630 /* Notice changes */
2631 if (p_ptr->stat_ind[i] != ind)
2632 {
2633 /* Save the new index */
2634 p_ptr->stat_ind[i] = ind;
2635
2636 /* Change in CON affects Hitpoints */
2637 if (i == A_CON)
2638 {
2639 p_ptr->update |= (PU_HP);
2640 }
2641
2642 /* Change in INT may affect Mana/Spells */
2643 else if (i == A_INT)
2644 {
2645 if (p_ptr->cp_ptr->spell_stat == A_INT)
2646 {
2647 p_ptr->update |= (PU_MANA | PU_SPELLS);
2648 }
2649 }
2650
2651 /* Change in WIS may affect Mana/Spells */
2652 else if (i == A_WIS)
2653 {
2654 if (p_ptr->cp_ptr->spell_stat == A_WIS)
2655 {
2656 p_ptr->update |= (PU_MANA | PU_SPELLS);
2657 }
2658 }
2659
2660 /* Window stuff */
2661 p_ptr->window |= (PW_PLAYER);
2662 }
2663 }
2664
2665
2666 /*** Temporary flags ***/
2667
2668 /* Apply temporary "stun" */
2669 if (p_ptr->stun > 50)
2670 {
2671 p_ptr->to_h -= 20;
2672 p_ptr->dis_to_h -= 20;
2673 p_ptr->to_d -= 20;
2674 p_ptr->dis_to_d -= 20;
2675 }
2676 else if (p_ptr->stun)
2677 {
2678 p_ptr->to_h -= 5;
2679 p_ptr->dis_to_h -= 5;
2680 p_ptr->to_d -= 5;
2681 p_ptr->dis_to_d -= 5;
2682 }
2683
2684
2685 /* Invulnerability */
2686 if (p_ptr->invuln)
2687 {
2688 p_ptr->to_a += 100;
2689 p_ptr->dis_to_a += 100;
2690 }
2691
2692 /* Temporary blessing */
2693 if (p_ptr->blessed)
2694 {
2695 p_ptr->to_a += 5;
2696 p_ptr->dis_to_a += 5;
2697 p_ptr->to_h += 10;
2698 p_ptr->dis_to_h += 10;
2699 }
2700
2701 /* Temprory shield */
2702 if (p_ptr->shield)
2703 {
2704 p_ptr->to_a += 50;
2705 p_ptr->dis_to_a += 50;
2706 }
2707
2708 /* Temporary "Hero" */
2709 if (p_ptr->hero)
2710 {
2711 p_ptr->to_h += 12;
2712 p_ptr->dis_to_h += 12;
2713 }
2714
2715 /* Temporary "Beserk" */
2716 if (p_ptr->shero)
2717 {
2718 p_ptr->to_h += 24;
2719 p_ptr->dis_to_h += 24;
2720 p_ptr->to_a -= 10;
2721 p_ptr->dis_to_a -= 10;
2722 }
2723
2724 /* Temporary "fast" */
2725 if (p_ptr->fast)
2726 {
2727 p_ptr->pspeed += 10;
2728 }
2729
2730 /* Temporary "slow" */
2731 if (p_ptr->slow)
2732 {
2733 p_ptr->pspeed -= 10;
2734 }
2735
2736 /* Temporary see invisible */
2737 if (p_ptr->tim_invis)
2738 {
2739 p_ptr->see_inv = TRUE;
2740 }
2741
2742 /* Temporary infravision boost */
2743 if (p_ptr->tim_infra)
2744 {
2745 p_ptr->see_infra++;
2746 }
2747
2748 /* Hack -- Res Chaos -> Res Conf */
2749 /* Not in recent Angband!
2750 if (p_ptr->resist_chaos)
2751 {
2752 p_ptr->resist_conf = TRUE;
2753 }
2754 */
2755
2756 /* Hack -- Hero/Shero -> Res fear */
2757 if (p_ptr->hero || p_ptr->shero)
2758 {
2759 p_ptr->resist_fear = TRUE;
2760 }
2761
2762
2763 /*** Analyze weight ***/
2764
2765 /* Extract the current weight (in tenth pounds) */
2766 j = p_ptr->total_weight;
2767
2768 /* Cap the weight */
2769 if (j > 1<<14) j = 1<<14;
2770
2771 /* Extract the "weight limit" (in tenth pounds) */
2772 i = weight_limit(p_ptr);
2773
2774 /* XXX XXX XXX Apply "encumbrance" from weight */
2775 if (j > i/2) p_ptr->pspeed -= ((j - (i/2)) / (i / 10));
2776
2777 /* Bloating slows the player down (a little) */
2778 if (p_ptr->food >= PY_FOOD_MAX) p_ptr->pspeed -= 10;
2779
2780 /* Searching slows the player down */
2781 /* -APD- adding "stealth mode" for rogues... will probably need to tweek this */
2782 if (p_ptr->searching)
2783 {
2784 if (!(p_ptr->cp_ptr->flags & CF_STEALTH_MODE)) p_ptr->pspeed -= 10;
2785 else
2786 {
2787 p_ptr->pspeed -= 10;
2788 p_ptr->skill_stl *= 3;
2789 }
2790 }
2791
2792 /*** Apply modifier bonuses ***/
2793
2794 /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
2795 p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
2796 p_ptr->to_d += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2797 p_ptr->to_h += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2798 p_ptr->to_h += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2799
2800 /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
2801 p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
2802 p_ptr->dis_to_d += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2803 p_ptr->dis_to_h += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2804 p_ptr->dis_to_h += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2805
2806
2807 /*** Modify skills ***/
2808
2809 /* Affect Skill -- stealth (bonus one) */
2810 p_ptr->skill_stl += 1;
2811
2812 /* Affect Skill -- disarming (DEX and INT) */
2813 p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
2814 p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
2815
2816 /* Affect Skill -- magic devices (INT) */
2817 p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
2818
2819 /* Affect Skill -- saving throw (WIS) */
2820 p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
2821
2822 /* Affect Skill -- digging (STR) */
2823 p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
2824
2825 /* Affect Skill -- disarming (Level, by Class) */
2826 p_ptr->skill_dis += (p_ptr->cp_ptr->x_dis * p_ptr->lev / 10);
2827
2828 /* Affect Skill -- magic devices (Level, by Class) */
2829 p_ptr->skill_dev += (p_ptr->cp_ptr->x_dev * p_ptr->lev / 10);
2830
2831 /* Affect Skill -- saving throw (Level, by Class) */
2832 p_ptr->skill_sav += (p_ptr->cp_ptr->x_sav * p_ptr->lev / 10);
2833
2834 /* Affect Skill -- stealth (Level, by Class) */
2835 p_ptr->skill_stl += (p_ptr->cp_ptr->x_stl * p_ptr->lev / 10);
2836
2837 /* Affect Skill -- search ability (Level, by Class) */
2838 p_ptr->skill_srh += (p_ptr->cp_ptr->x_srh * p_ptr->lev / 10);
2839
2840 /* Affect Skill -- search frequency (Level, by Class) */
2841 p_ptr->skill_fos += (p_ptr->cp_ptr->x_fos * p_ptr->lev / 10);
2842
2843 /* Affect Skill -- combat (normal) (Level, by Class) */
2844 p_ptr->skill_thn += (p_ptr->cp_ptr->x_thn * p_ptr->lev / 10);
2845
2846 /* Affect Skill -- combat (shooting) (Level, by Class) */
2847 p_ptr->skill_thb += (p_ptr->cp_ptr->x_thb * p_ptr->lev / 10);
2848
2849 /* Affect Skill -- combat (throwing) (Level, by Class) */
2850 p_ptr->skill_tht += (p_ptr->cp_ptr->x_thb * p_ptr->lev / 10);
2851
2852 /* Limit Skill -- stealth from 0 to 30 */
2853 if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
2854 if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
2855
2856 /* Limit Skill -- digging from 1 up */
2857 if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
2858
2859 /* Limit final infravision to >= 0 */
2860 if (p_ptr->see_infra < 0) p_ptr->see_infra = 0;
2861
2862 /* Obtain the "hold" value */
2863 hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
2864
2865
2866 /*** Analyze current bow ***/
2867
2868 /* Examine the "current bow" */
2869 o_ptr = &p_ptr->inventory[INVEN_BOW];
2870
2871 /* Assume not heavy */
2872 p_ptr->heavy_shoot = FALSE;
2873
2874 /* It is hard to carholdry a heavy bow */
2875 if (hold < o_ptr->weight / 10)
2876 {
2877 /* Hard to wield a heavy bow */
2878 p_ptr->to_h += 2 * (hold - o_ptr->weight / 10);
2879 p_ptr->dis_to_h += 2 * (hold - o_ptr->weight / 10);
2880
2881 /* Heavy Bow */
2882 p_ptr->heavy_shoot = TRUE;
2883 }
2884
2885 /* Compute "extra shots" if needed */
2886 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
2887 {
2888 /* Take note of required "tval" for missiles */
2889 switch (o_ptr->sval)
2890 {
2891 case SV_SLING:
2892 {
2893 p_ptr->tval_ammo = TV_SHOT;
2894 break;
2895 }
2896
2897 case SV_SHORT_BOW:
2898 case SV_LONG_BOW:
2899 {
2900 p_ptr->tval_ammo = TV_ARROW;
2901 break;
2902 }
2903
2904 case SV_LIGHT_XBOW:
2905 case SV_HEAVY_XBOW:
2906 {
2907 p_ptr->tval_ammo = TV_BOLT;
2908 break;
2909 }
2910 }
2911
2912 /* Hack -- Reward High Level Rangers using Bows */
2913 if ((p_ptr->cp_ptr->flags & CF_EXTRA_SHOT) && (p_ptr->tval_ammo == TV_ARROW))
2914 {
2915 /* Extra shot at level 20 */
2916 if (p_ptr->lev >= 20) p_ptr->num_fire++;
2917
2918 /* Extra shot at level 40 */
2919 if (p_ptr->lev >= 40) p_ptr->num_fire++;
2920 }
2921
2922 /* Add in the "bonus shots" */
2923 p_ptr->num_fire += extra_shots;
2924
2925 /* Require at least one shot */
2926 if (p_ptr->num_fire < 1) p_ptr->num_fire = 1;
2927 }
2928
2929
2930 /*** Analyze weapon ***/
2931
2932 /* Examine the "main weapon" */
2933 o_ptr = &p_ptr->inventory[INVEN_WIELD];
2934
2935 /* Assume not heavy */
2936 p_ptr->heavy_wield = FALSE;
2937
2938 /* It is hard to hold a heavy weapon */
2939 if (hold < o_ptr->weight / 10)
2940 {
2941 /* Hard to wield a heavy weapon */
2942 p_ptr->to_h += 2 * (hold - o_ptr->weight / 10);
2943 p_ptr->dis_to_h += 2 * (hold - o_ptr->weight / 10);
2944
2945 /* Heavy weapon */
2946 p_ptr->heavy_wield = TRUE;
2947 }
2948
2949
2950 /* Normal weapons */
2951 if (o_ptr->k_idx && !p_ptr->heavy_wield)
2952 {
2953 int str_index, dex_index;
2954
2955 int div = 0;
2956
2957 /* Enforce a minimum "weight" (tenth pounds) */
2958 div = ((o_ptr->weight < p_ptr->cp_ptr->min_weight) ? p_ptr->cp_ptr->min_weight : o_ptr->weight);
2959
2960 /* Access the strength vs weight */
2961 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * p_ptr->cp_ptr->att_multiply / div);
2962
2963 /* Maximal value */
2964 if (str_index > 11) str_index = 11;
2965
2966 /* Index by dexterity */
2967 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
2968
2969 /* Maximal value */
2970 if (dex_index > 11) dex_index = 11;
2971
2972 /* Use the blows table */
2973 p_ptr->num_blow = blows_table[str_index][dex_index];
2974
2975 /* Maximal value */
2976 if (p_ptr->num_blow > p_ptr->cp_ptr->max_attacks) p_ptr->num_blow = p_ptr->cp_ptr->max_attacks;
2977
2978 /* Add in the "bonus blows" */
2979 p_ptr->num_blow += extra_blows;
2980
2981 /* Require at least one blow */
2982 if (p_ptr->num_blow < 1) p_ptr->num_blow = 1;
2983
2984 /* Boost digging skill by weapon weight */
2985 p_ptr->skill_dig += (o_ptr->weight / 10);
2986 }
2987
2988
2989 /* Assume okay */
2990 p_ptr->icky_wield = FALSE;
2991
2992 /* Priest weapon penalty for non-blessed edged weapons */
2993 if ((p_ptr->cp_ptr->flags & CF_BLESS_WEAPON) && (!p_ptr->bless_blade) &&
2994 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
2995 {
2996 /* Reduce the real bonuses */
2997 p_ptr->to_h -= 2;
2998 p_ptr->to_d -= 2;
2999
3000 /* Reduce the mental bonuses */
3001 p_ptr->dis_to_h -= 2;
3002 p_ptr->dis_to_d -= 2;
3003
3004 /* Icky weapon */
3005 p_ptr->icky_wield = TRUE;
3006 }
3007
3008 /* Hack -- ensure speed is in bounds */
3009 if (p_ptr->pspeed < 0) p_ptr->pspeed = 0;
3010 if (p_ptr->pspeed > 199) p_ptr->pspeed = 199;
3011
3012
3013 /*** Notice changes ***/
3014
3015 /* Note -- unlike angband, stat changes are noticed when updated (see above) */
3016
3017 /* Hack -- Telepathy Change */
3018 if (p_ptr->telepathy != old_telepathy)
3019 {
3020 p_ptr->update |= (PU_MONSTERS);
3021 }
3022
3023 /* Hack -- See Invis Change */
3024 if (p_ptr->see_inv != old_see_inv)
3025 {
3026 p_ptr->update |= (PU_MONSTERS);
3027 }
3028
3029 /* Display the speed (if needed) */
3030 if (p_ptr->pspeed != old_speed) p_ptr->redraw |= (PR_SPEED);
3031
3032 /* Redraw armor (if needed) */
3033 if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
3034 {
3035 /* Redraw */
3036 p_ptr->redraw |= (PR_ARMOR);
3037
3038 /* Window stuff */
3039 p_ptr->window |= (PW_PLAYER);
3040 }
3041
3042 /* Redraw To-Hit and To-Dim (if needed) */
3043 if ((p_ptr->dis_to_h != old_dis_to_h) || (p_ptr->dis_to_d != old_dis_to_d))
3044 {
3045 /* Redraw */
3046 p_ptr->redraw |= (PR_PLUSSES);
3047 }
3048
3049 /* Hack -- handle "xtra" mode */
3050 /*if (character_xtra) return;*/
3051
3052 /* Take note when "heavy bow" changes */
3053 if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
3054 {
3055 /* Message */
3056 if (p_ptr->heavy_shoot)
3057 {
3058 msg_print(p_ptr, "You have trouble wielding such a heavy bow.");
3059 }
3060 else if (p_ptr->inventory[INVEN_BOW].k_idx)
3061 {
3062 msg_print(p_ptr, "You have no trouble wielding your bow.");
3063 }
3064 else
3065 {
3066 msg_print(p_ptr, "You feel relieved to put down your heavy bow.");
3067 }
3068
3069 /* Save it */
3070 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
3071 }
3072
3073 /* Take note when "heavy weapon" changes */
3074 if (p_ptr->old_heavy_wield != p_ptr->heavy_wield)
3075 {
3076 /* Message */
3077 if (p_ptr->heavy_wield)
3078 {
3079 msg_print(p_ptr, "You have trouble wielding such a heavy weapon.");
3080 }
3081 else if (p_ptr->inventory[INVEN_WIELD].k_idx)
3082 {
3083 msg_print(p_ptr, "You have no trouble wielding your weapon.");
3084 }
3085 else
3086 {
3087 msg_print(p_ptr, "You feel relieved to put down your heavy weapon.");
3088 }
3089
3090 /* Save it */
3091 p_ptr->old_heavy_wield = p_ptr->heavy_wield;
3092 }
3093
3094 /* Take note when "illegal weapon" changes */
3095 if (p_ptr->old_icky_wield != p_ptr->icky_wield)
3096 {
3097 /* Message */
3098 if (p_ptr->icky_wield)
3099 {
3100 msg_print(p_ptr, "You do not feel comfortable with your weapon.");
3101 }
3102 else if (p_ptr->inventory[INVEN_WIELD].k_idx)
3103 {
3104 msg_print(p_ptr, "You feel comfortable with your weapon.");
3105 }
3106 else
3107 {
3108 msg_print(p_ptr, "You feel more comfortable after removing your weapon.");
3109 }
3110
3111 /* Save it */
3112 p_ptr->old_icky_wield = p_ptr->icky_wield;
3113 }
3114
3115 /* XXX - Always resend skills */
3116 p_ptr->redraw |= (PR_SKILLS);
3117 }
3118
3119
3120
3121 /*
3122 * Handle "p_ptr->notice"
3123 */
notice_stuff(player_type * p_ptr)3124 void notice_stuff(player_type *p_ptr)
3125 {
3126 /* Notice stuff */
3127 if (!p_ptr->notice) return;
3128
3129
3130 /* Combine the pack */
3131 if (p_ptr->notice & PN_COMBINE)
3132 {
3133 p_ptr->notice &= ~(PN_COMBINE);
3134 combine_pack(p_ptr);
3135 }
3136
3137 /* Reorder the pack */
3138 if (p_ptr->notice & PN_REORDER)
3139 {
3140 p_ptr->notice &= ~(PN_REORDER);
3141 reorder_pack(p_ptr);
3142 }
3143 }
3144
3145
3146 /*
3147 * Handle "p_ptr->update"
3148 */
update_stuff(player_type * p_ptr)3149 void update_stuff(player_type *p_ptr)
3150 {
3151 /* Update stuff */
3152 if (!p_ptr->update) return;
3153
3154
3155 if (p_ptr->update & PU_BONUS)
3156 {
3157 p_ptr->update &= ~(PU_BONUS);
3158 calc_bonuses(p_ptr);
3159 }
3160
3161 if (p_ptr->update & PU_TORCH)
3162 {
3163 p_ptr->update &= ~(PU_TORCH);
3164 calc_torch(p_ptr);
3165 }
3166
3167 if (p_ptr->update & PU_HP)
3168 {
3169 p_ptr->update &= ~(PU_HP);
3170 calc_hitpoints(p_ptr);
3171 }
3172
3173 if (p_ptr->update & PU_MANA)
3174 {
3175 p_ptr->update &= ~(PU_MANA);
3176 calc_mana(p_ptr);
3177 }
3178
3179 if (p_ptr->update & PU_SPELLS)
3180 {
3181 p_ptr->update &= ~(PU_SPELLS);
3182 calc_spells(p_ptr);
3183 }
3184
3185
3186 /* Character is not ready yet, no screen updates */
3187 /*if (!character_generated) return;*/
3188
3189
3190 /* Character is in "icky" mode, no screen updates */
3191 /*if (character_icky) return;*/
3192
3193 /* Character has changed depth very recently, no screen updates */
3194 if (p_ptr->new_level_flag) return;
3195
3196 if (p_ptr->update & PU_UN_LITE)
3197 {
3198 p_ptr->update &= ~(PU_UN_LITE);
3199 forget_lite(p_ptr);
3200 }
3201
3202 if (p_ptr->update & PU_UN_VIEW)
3203 {
3204 p_ptr->update &= ~(PU_UN_VIEW);
3205 forget_view(p_ptr);
3206 }
3207
3208
3209 if (p_ptr->update & PU_VIEW)
3210 {
3211 p_ptr->update &= ~(PU_VIEW);
3212 update_view(p_ptr);
3213 }
3214
3215 if (p_ptr->update & PU_LITE)
3216 {
3217 p_ptr->update &= ~(PU_LITE);
3218 update_lite(p_ptr);
3219 }
3220
3221
3222 if (p_ptr->update & PU_FLOW)
3223 {
3224 p_ptr->update &= ~(PU_FLOW);
3225 update_flow();
3226 }
3227
3228
3229 if (p_ptr->update & PU_DISTANCE)
3230 {
3231 p_ptr->update &= ~(PU_DISTANCE);
3232 p_ptr->update &= ~(PU_MONSTERS);
3233 update_monsters(TRUE);
3234 update_players();
3235 }
3236
3237 if (p_ptr->update & PU_MONSTERS)
3238 {
3239 p_ptr->update &= ~(PU_MONSTERS);
3240 update_monsters(FALSE);
3241 update_players();
3242 }
3243 }
3244
3245
3246 /*
3247 * Handle "p_ptr->redraw"
3248 */
redraw_stuff(player_type * p_ptr)3249 void redraw_stuff(player_type *p_ptr)
3250 {
3251 /* Redraw stuff */
3252 if (!p_ptr->redraw) return;
3253
3254
3255 /* Character is not ready yet, no screen updates */
3256 /*if (!character_generated) return;*/
3257
3258
3259 /* Character is in "icky" mode, no screen updates */
3260 /*if (character_icky) return;*/
3261
3262
3263
3264 /* Hack -- clear the screen */
3265 if (p_ptr->redraw & PR_WIPE)
3266 {
3267 p_ptr->redraw &= ~PR_WIPE;
3268 msg_print(p_ptr, NULL);
3269 /*Term_clear();*/
3270 }
3271
3272
3273 if (p_ptr->redraw & PR_MAP)
3274 {
3275 p_ptr->redraw &= ~(PR_MAP);
3276 prt_map(p_ptr);
3277 }
3278
3279 if (p_ptr->redraw & PR_MISC)
3280 {
3281 p_ptr->redraw &= ~(PR_MISC);
3282 send_character_info(p_ptr);
3283 prt_misc(p_ptr);
3284 /*prt_history(p_ptr);*/
3285 }
3286
3287 if (p_ptr->redraw & PR_TITLE)
3288 {
3289 p_ptr->redraw &= ~(PR_TITLE);
3290 prt_title(p_ptr);
3291 }
3292
3293 if (p_ptr->redraw & PR_LEV)
3294 {
3295 p_ptr->redraw &= ~(PR_LEV);
3296 prt_level(p_ptr);
3297 }
3298
3299 if (p_ptr->redraw & PR_EXP)
3300 {
3301 p_ptr->redraw &= ~(PR_EXP);
3302 prt_exp(p_ptr);
3303 }
3304
3305 if (p_ptr->redraw & PR_STATS)
3306 {
3307 p_ptr->redraw &= ~(PR_STATS);
3308 prt_stat(p_ptr, A_STR);
3309 prt_stat(p_ptr, A_INT);
3310 prt_stat(p_ptr, A_WIS);
3311 prt_stat(p_ptr, A_DEX);
3312 prt_stat(p_ptr, A_CON);
3313 prt_stat(p_ptr, A_CHR);
3314 }
3315
3316 if (p_ptr->redraw & PR_ARMOR)
3317 {
3318 p_ptr->redraw &= ~(PR_ARMOR);
3319 prt_ac(p_ptr);
3320 }
3321
3322 if (p_ptr->redraw & PR_HP)
3323 {
3324 p_ptr->redraw &= ~(PR_HP);
3325 prt_hp(p_ptr);
3326 }
3327
3328 if (p_ptr->redraw & PR_MANA)
3329 {
3330 p_ptr->redraw &= ~(PR_MANA);
3331 prt_sp(p_ptr);
3332 }
3333
3334 if (p_ptr->redraw & PR_GOLD)
3335 {
3336 p_ptr->redraw &= ~(PR_GOLD);
3337 prt_gold(p_ptr);
3338 }
3339
3340 if (p_ptr->redraw & PR_DEPTH)
3341 {
3342 p_ptr->redraw &= ~(PR_DEPTH);
3343 prt_depth(p_ptr);
3344 }
3345
3346 if (p_ptr->redraw & PR_HEALTH)
3347 {
3348 p_ptr->redraw &= ~(PR_HEALTH);
3349 health_redraw(p_ptr);
3350 }
3351
3352 if (p_ptr->redraw & PR_CURSOR)
3353 {
3354 p_ptr->redraw &= ~(PR_CURSOR);
3355 cursor_redraw(p_ptr);
3356 }
3357
3358 /*if (p_ptr->redraw & PR_HISTORY)
3359 {
3360 p_ptr->redraw &= ~(PR_HISTORY);
3361 prt_history(p_ptr);
3362 }*/
3363
3364 if (p_ptr->redraw & PR_OFLAGS)
3365 {
3366 p_ptr->redraw &= ~(PR_OFLAGS);
3367 prt_flags(p_ptr);
3368 /* HACK - since OFLAGS mostly indicates changes in equipment,
3369 * we can use it trigger inscription updates. FIXME? */
3370 update_prevent_inscriptions(p_ptr);
3371 }
3372
3373 if (p_ptr->redraw & PR_VARIOUS)
3374 {
3375 p_ptr->redraw &= ~(PR_VARIOUS);
3376 prt_various(p_ptr);
3377 }
3378
3379 if (p_ptr->redraw & PR_PLUSSES)
3380 {
3381 p_ptr->redraw &= ~(PR_PLUSSES);
3382 prt_plusses(p_ptr);
3383 }
3384
3385 if (p_ptr->redraw & PR_SKILLS)
3386 {
3387 p_ptr->redraw &= ~(PR_SKILLS);
3388 prt_skills(p_ptr);
3389 }
3390
3391 if (p_ptr->redraw & PR_CUT)
3392 {
3393 p_ptr->redraw &= ~(PR_CUT);
3394 prt_cut(p_ptr);
3395 }
3396
3397 if (p_ptr->redraw & PR_STUN)
3398 {
3399 p_ptr->redraw &= ~(PR_STUN);
3400 prt_stun(p_ptr);
3401 }
3402
3403 if (p_ptr->redraw & PR_HUNGER)
3404 {
3405 p_ptr->redraw &= ~(PR_HUNGER);
3406 prt_hunger(p_ptr);
3407 }
3408
3409 if (p_ptr->redraw & PR_BLIND)
3410 {
3411 p_ptr->redraw &= ~(PR_BLIND);
3412 prt_blind(p_ptr);
3413 }
3414
3415 if (p_ptr->redraw & PR_CONFUSED)
3416 {
3417 p_ptr->redraw &= ~(PR_CONFUSED);
3418 prt_confused(p_ptr);
3419 }
3420
3421 if (p_ptr->redraw & PR_AFRAID)
3422 {
3423 p_ptr->redraw &= ~(PR_AFRAID);
3424 prt_afraid(p_ptr);
3425 }
3426
3427 if (p_ptr->redraw & PR_POISONED)
3428 {
3429 p_ptr->redraw &= ~(PR_POISONED);
3430 prt_poisoned(p_ptr);
3431 }
3432
3433 if (p_ptr->redraw & PR_STATE)
3434 {
3435 p_ptr->redraw &= ~(PR_STATE);
3436 prt_state(p_ptr);
3437 }
3438
3439 if (p_ptr->redraw & PR_SPEED)
3440 {
3441 p_ptr->redraw &= ~(PR_SPEED);
3442 prt_speed(p_ptr);
3443 }
3444
3445 if (p_ptr->redraw & PR_STUDY)
3446 {
3447 p_ptr->redraw &= ~(PR_STUDY);
3448 prt_study(p_ptr);
3449 }
3450
3451 if (p_ptr->redraw & PR_FLOOR)
3452 {
3453 p_ptr->redraw &= ~(PR_FLOOR);
3454 prt_floor_item(p_ptr);
3455 }
3456
3457 if (p_ptr->redraw & PR_OPPOSE_ELEMENTS)
3458 {
3459 p_ptr->redraw &= ~(PR_OPPOSE_ELEMENTS);
3460 prt_oppose_elements(p_ptr);
3461 }
3462 }
3463
3464
3465 /*
3466 * Handle "p_ptr->window"
3467 */
window_stuff(player_type * p_ptr)3468 void window_stuff(player_type *p_ptr)
3469 {
3470 /* Window stuff */
3471 if (!p_ptr->window) return;
3472
3473 /* Display inventory */
3474 if (p_ptr->window & PW_INVEN)
3475 {
3476 p_ptr->window &= ~(PW_INVEN);
3477 /* Note: PW_INVEN has been disabled and does absolutely
3478 * nothing! To inform client about inventory changes,
3479 * set relevant bits in 'redraw_inven'. */
3480 /* p_ptr->redraw_inven = 0xFFFFFFFFFFFFFFFFLL;
3481 fix_inven(p_ptr); */
3482 }
3483
3484 /* Display equipment */
3485 if (p_ptr->window & PW_EQUIP)
3486 {
3487 p_ptr->window &= ~(PW_EQUIP);
3488 /* Note: PW_EQUIP has been disabled and does absolutely
3489 * nothing! To inform client about inventory changes,
3490 * set relevant bits in 'redraw_inven'. */
3491 /* fix_equip(p_ptr);
3492 p_ptr->redraw_inven = 0xFFFFFFFFFFFFFFFFLL; */
3493 }
3494
3495 /* Display spell list */
3496 if (p_ptr->window & PW_SPELL)
3497 {
3498 p_ptr->window &= ~(PW_SPELL);
3499 fix_spell(p_ptr);
3500 }
3501
3502 /* Display player */
3503 if (p_ptr->window & PW_PLAYER)
3504 {
3505 p_ptr->window &= ~(PW_PLAYER);
3506 fix_player(p_ptr);
3507 }
3508
3509 /* Display message view */
3510 if (p_ptr->window & PW_MESSAGE)
3511 {
3512 p_ptr->window &= ~(PW_MESSAGE);
3513 fix_message(p_ptr);
3514 }
3515
3516 /* Display overhead view */
3517 if (p_ptr->window & PW_OVERHEAD)
3518 {
3519 p_ptr->window &= ~(PW_OVERHEAD);
3520 fix_overhead(p_ptr);
3521 }
3522
3523 /* Display mini-map view */
3524 if (p_ptr->window & PW_MAP)
3525 {
3526 p_ptr->window &= ~(PW_MAP);
3527 fix_map(p_ptr);
3528 }
3529
3530 /* Display monster recall */
3531 if (p_ptr->window & PW_MONSTER)
3532 {
3533 p_ptr->window &= ~(PW_MONSTER);
3534 fix_monster(p_ptr);
3535 }
3536
3537 /* Display monster list */
3538 if (p_ptr->window & PW_MONLIST)
3539 {
3540 p_ptr->window &= ~(PW_MONLIST);
3541 fix_monlist(p_ptr);
3542 }
3543
3544 /* Display item list */
3545 if (p_ptr->window & PW_ITEMLIST)
3546 {
3547 p_ptr->window &= ~(PW_ITEMLIST);
3548 fix_itemlist(p_ptr);
3549 }
3550 }
3551
3552
3553 /*
3554 * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
3555 */
handle_stuff(player_type * p_ptr)3556 void handle_stuff(player_type *p_ptr)
3557 {
3558 if (p_ptr->conn == -1 || !IS_PLAYING(p_ptr)) return;
3559
3560 /* Hack -- delay updating */
3561 if (p_ptr->new_level_flag) return;
3562
3563 /* Update stuff */
3564 if (p_ptr->update) update_stuff(p_ptr);
3565
3566 /* Redraw inventory */
3567 if (p_ptr->redraw_inven)
3568 {
3569 fix_inven(p_ptr);
3570 fix_equip(p_ptr);
3571 p_ptr->redraw_inven = 0;
3572 }
3573
3574 /* Redraw stuff */
3575 if (p_ptr->redraw) redraw_stuff(p_ptr);
3576
3577 /* Window stuff */
3578 if (p_ptr->window) window_stuff(p_ptr);
3579 }
3580