OSDN Git Service

毒針を装備している時は必ず攻撃回数を1にするようにした。(乱れ雪月花で増えない)
[hengband/hengband.git] / src / avatar.c
1 /* File: avatar.c */
2
3 /*
4  * Purpose: Enable an Ultima IV style "avatar" game where you try to
5  * achieve perfection in various virtues.
6  *
7  * Topi Ylinen 1998
8  * f1toyl@uta.fi
9  * topi.ylinen@noodi.fi
10  *
11  */
12
13 /*
14  * Copyright (c) 1989 James E. Wilson, Christopher J. Stuart
15  *
16  * This software may be copied and distributed for educational, research, and
17  * not for profit purposes provided that this copyright and statement are
18  * included in all such copies.
19  */
20
21 #include "angband.h"
22
23
24 /* The names of the virtues */
25
26 cptr virtue[MAX_VIRTUE] =
27 {
28 #ifdef JP
29         "¾ð",
30         "ÍÀ",
31         "Àµ",
32         "µ¾",
33         "¼±",
34         "À¿",
35         "·¼",
36         "Èë",
37         "±¿",
38         "Á³",
39         "Ĵ",
40         "³è",
41         "»à",
42         "Ǧ",
43         "Àá",
44         "¶Ð",
45         "ͦ",
46         "¸Ä",
47 #else
48         "Compassion",
49         "Honour",
50         "Justice",
51         "Sacrifice",
52         "Knowledge",
53         "Faith",
54         "Enlightenment",
55         "Mysticism",
56         "Chance",
57         "Nature",
58         "Harmony",
59         "Vitality",
60         "Unlife",
61         "Patience",
62         "Temperance",
63         "Diligence",
64         "Valour",
65         "Individualism",
66 #endif
67 };
68
69
70 bool compare_virtue(int type, int num, int tekitou)
71 {
72         int vir;
73         if (virtue_number(type))
74                 vir = p_ptr->virtues[virtue_number(type) - 1];
75         else
76                 vir = 0;
77
78         switch (tekitou)
79         {
80         case VIRTUE_LARGE:
81                 if (vir > num) return TRUE;
82                 else return FALSE;
83         case VIRTUE_SMALL:
84                 if (vir < num) return TRUE;
85                 else return FALSE;
86         }
87
88         return FALSE;
89 }
90
91
92 /* Aux function */
93
94 int virtue_number(int type)
95 {
96         int i;
97
98         /* Search */
99         for (i = 0; i < 8; i++)
100         {
101                 if (p_ptr->vir_types[i] == type) return i + 1;
102         }
103
104         /* No match */
105         return 0;
106 }
107
108 /* Aux function */
109
110 static void get_random_virtue(int which)
111 {
112         int type = 0;
113
114         /* Randomly choose a type */
115         while (!(type) || virtue_number(type))
116         {
117                 switch (randint1(29))
118                 {
119                 case 1: case 2: case 3:
120                         type = V_SACRIFICE;
121                         break;
122                 case 4: case 5: case 6:
123                         type = V_COMPASSION;
124                         break;
125                 case 7: case 8: case 9: case 10: case 11: case 12:
126                         type = V_VALOUR;
127                         break;
128                 case 13: case 14: case 15: case 16: case 17:
129                         type = V_HONOUR;
130                         break;
131                 case 18: case 19: case 20: case 21:
132                         type = V_JUSTICE;
133                         break;
134                 case 22: case 23:
135                         type = V_TEMPERANCE;
136                         break;
137                 case 24: case 25:
138                         type = V_HARMONY;
139                         break;
140                 case 26: case 27: case 28:
141                         type = V_PATIENCE;
142                         break;
143                 default:
144                         type = V_DILIGENCE;
145                         break;
146                 }
147         }
148
149         /* Chosen */
150         p_ptr->vir_types[which] = type;
151 }
152
153 static s16b get_realm_virtues(byte realm)
154 {
155         switch (realm)
156         {
157         case REALM_LIFE:
158                 if (virtue_number(V_VITALITY)) return V_TEMPERANCE;
159                 else return V_VITALITY;
160         case REALM_SORCERY:
161                 if (virtue_number(V_KNOWLEDGE)) return V_ENCHANT;
162                 else return V_KNOWLEDGE;
163         case REALM_NATURE:
164                 if (virtue_number(V_NATURE)) return V_HARMONY;
165                 else return V_NATURE;
166         case REALM_CHAOS:
167                 if (virtue_number(V_CHANCE)) return V_INDIVIDUALISM;
168                 else return V_CHANCE;
169         case REALM_DEATH:
170                 return V_UNLIFE;
171         case REALM_TRUMP:
172                 return V_KNOWLEDGE;
173         case REALM_ARCANE:
174                 return 0;
175         case REALM_CRAFT:
176                 if (virtue_number(V_ENCHANT)) return V_INDIVIDUALISM;
177                 else return V_ENCHANT;
178         case REALM_DAEMON:
179                 if (virtue_number(V_JUSTICE)) return V_FAITH;
180                 else return V_JUSTICE;
181         case REALM_CRUSADE:
182                 if (virtue_number(V_JUSTICE)) return V_HONOUR;
183                 else return V_JUSTICE;
184         };
185
186         return 0;
187 }
188
189 /* Select virtues & reset values for a new character */
190
191 void get_virtues(void)
192 {
193         int i = 0, j = 0;
194         s16b tmp_vir;
195
196         /* Reset */
197         for (i = 0; i < 8; i++)
198         {
199                 p_ptr->virtues[i] = 0;
200                 p_ptr->vir_types[i] = 0;
201         }
202
203         i = 0;
204
205         /* Get pre-defined types */
206         /* 1 or more virtues based on class */
207         switch (p_ptr->pclass)
208         {
209         case CLASS_WARRIOR:
210         case CLASS_SAMURAI:
211                 p_ptr->vir_types[i++] = V_VALOUR;
212                 p_ptr->vir_types[i++] = V_HONOUR;
213                 break;
214         case CLASS_MAGE:
215                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
216                 p_ptr->vir_types[i++] = V_ENCHANT;
217                 break;
218         case CLASS_PRIEST:
219                 p_ptr->vir_types[i++] = V_FAITH;
220                 p_ptr->vir_types[i++] = V_TEMPERANCE;
221                 break;
222         case CLASS_ROGUE:
223                 p_ptr->vir_types[i++] = V_HONOUR;
224                 break;
225         case CLASS_RANGER:
226         case CLASS_ARCHER:
227                 p_ptr->vir_types[i++] = V_NATURE;
228                 p_ptr->vir_types[i++] = V_TEMPERANCE;
229                 break;
230         case CLASS_PALADIN:
231                 p_ptr->vir_types[i++] = V_JUSTICE;
232                 p_ptr->vir_types[i++] = V_VALOUR;
233                 p_ptr->vir_types[i++] = V_HONOUR;
234                 p_ptr->vir_types[i++] = V_FAITH;
235                 break;
236         case CLASS_WARRIOR_MAGE:
237         case CLASS_RED_MAGE:
238                 p_ptr->vir_types[i++] = V_ENCHANT;
239                 p_ptr->vir_types[i++] = V_VALOUR;
240                 break;
241         case CLASS_CHAOS_WARRIOR:
242                 p_ptr->vir_types[i++] = V_CHANCE;
243                 p_ptr->vir_types[i++] = V_INDIVIDUALISM;
244                 break;
245         case CLASS_MONK:
246         case CLASS_FORCETRAINER:
247                 p_ptr->vir_types[i++] = V_FAITH;
248                 p_ptr->vir_types[i++] = V_HARMONY;
249                 p_ptr->vir_types[i++] = V_TEMPERANCE;
250                 p_ptr->vir_types[i++] = V_PATIENCE;
251                 break;
252         case CLASS_MINDCRAFTER:
253         case CLASS_MIRROR_MASTER:
254                 p_ptr->vir_types[i++] = V_HARMONY;
255                 p_ptr->vir_types[i++] = V_ENLIGHTEN;
256                 p_ptr->vir_types[i++] = V_PATIENCE;
257                 break;
258         case CLASS_HIGH_MAGE:
259         case CLASS_SORCERER:
260                 p_ptr->vir_types[i++] = V_ENLIGHTEN;
261                 p_ptr->vir_types[i++] = V_ENCHANT;
262                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
263                 break;
264         case CLASS_TOURIST:
265                 p_ptr->vir_types[i++] = V_ENLIGHTEN;
266                 p_ptr->vir_types[i++] = V_CHANCE;
267                 break;
268         case CLASS_IMITATOR:
269                 p_ptr->vir_types[i++] = V_CHANCE;
270                 break;
271         case CLASS_BLUE_MAGE:
272                 p_ptr->vir_types[i++] = V_CHANCE;
273                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
274                 break;
275         case CLASS_BEASTMASTER:
276                 p_ptr->vir_types[i++] = V_NATURE;
277                 p_ptr->vir_types[i++] = V_CHANCE;
278                 p_ptr->vir_types[i++] = V_VITALITY;
279                 break;
280         case CLASS_MAGIC_EATER:
281                 p_ptr->vir_types[i++] = V_ENCHANT;
282                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
283                 break;
284         case CLASS_BARD:
285                 p_ptr->vir_types[i++] = V_HARMONY;
286                 p_ptr->vir_types[i++] = V_COMPASSION;
287                 break;
288         case CLASS_CAVALRY:
289                 p_ptr->vir_types[i++] = V_VALOUR;
290                 p_ptr->vir_types[i++] = V_HARMONY;
291                 break;
292         case CLASS_BERSERKER:
293                 p_ptr->vir_types[i++] = V_VALOUR;
294                 p_ptr->vir_types[i++] = V_INDIVIDUALISM;
295                 break;
296         case CLASS_SMITH:
297                 p_ptr->vir_types[i++] = V_HONOUR;
298                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
299                 break;
300         case CLASS_NINJA:
301                 p_ptr->vir_types[i++] = V_PATIENCE;
302                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
303                 p_ptr->vir_types[i++] = V_FAITH;
304                 p_ptr->vir_types[i++] = V_UNLIFE;
305                 break;
306         };
307
308         /* Get one virtue based on race */
309         switch (p_ptr->prace)
310         {
311         case RACE_HUMAN: case RACE_HALF_ELF: case RACE_DUNADAN:
312                 p_ptr->vir_types[i++] = V_INDIVIDUALISM;
313                 break;
314         case RACE_ELF: case RACE_SPRITE: case RACE_ENT:
315                 p_ptr->vir_types[i++] = V_NATURE;
316                 break;
317         case RACE_HOBBIT: case RACE_HALF_OGRE:
318                 p_ptr->vir_types[i++] = V_TEMPERANCE;
319                 break;
320         case RACE_DWARF: case RACE_KLACKON: case RACE_ANDROID:
321                 p_ptr->vir_types[i++] = V_DILIGENCE;
322                 break;
323         case RACE_GNOME: case RACE_CYCLOPS:
324                 p_ptr->vir_types[i++] = V_KNOWLEDGE;
325                 break;
326         case RACE_HALF_ORC: case RACE_AMBERITE: case RACE_KOBOLD:
327                 p_ptr->vir_types[i++] = V_HONOUR;
328                 break;
329         case RACE_HALF_TROLL: case RACE_BARBARIAN:
330                 p_ptr->vir_types[i++] = V_VALOUR;
331                 break;
332         case RACE_HIGH_ELF: case RACE_KUTA:
333                 p_ptr->vir_types[i++] = V_VITALITY;
334                 break;
335         case RACE_HALF_GIANT: case RACE_GOLEM: case RACE_ANGEL: case RACE_DEMON:
336                 p_ptr->vir_types[i++] = V_JUSTICE;
337                 break;
338         case RACE_HALF_TITAN:
339                 p_ptr->vir_types[i++] = V_HARMONY;
340                 break;
341         case RACE_YEEK:
342                 p_ptr->vir_types[i++] = V_SACRIFICE;
343                 break;
344         case RACE_MIND_FLAYER:
345                 p_ptr->vir_types[i++] = V_ENLIGHTEN;
346                 break;
347         case RACE_DARK_ELF: case RACE_DRACONIAN: case RACE_S_FAIRY:
348                 p_ptr->vir_types[i++] = V_ENCHANT;
349                 break;
350         case RACE_NIBELUNG:
351                 p_ptr->vir_types[i++] = V_PATIENCE;
352                 break;
353         case RACE_IMP:
354                 p_ptr->vir_types[i++] = V_FAITH;
355                 break;
356         case RACE_ZOMBIE: case RACE_SKELETON:
357         case RACE_VAMPIRE: case RACE_SPECTRE:
358                 p_ptr->vir_types[i++] = V_UNLIFE;
359                 break;
360         case RACE_BEASTMAN:
361                 p_ptr->vir_types[i++] = V_CHANCE;
362                 break;
363         }
364
365         /* Get a virtue for realms */
366         if (p_ptr->realm1)
367         {
368                 tmp_vir = get_realm_virtues(p_ptr->realm1);
369                 if (tmp_vir) p_ptr->vir_types[i++] = tmp_vir;
370         }
371         if (p_ptr->realm2)
372         {
373                 tmp_vir = get_realm_virtues(p_ptr->realm2);
374                 if (tmp_vir) p_ptr->vir_types[i++] = tmp_vir;
375         }
376
377         /* Eliminate doubles */
378         for (i = 0; i < 8; i++)
379         {
380                 for (j = i + 1; j < 8; j++)
381                 {
382                         if ((p_ptr->vir_types[j] != 0) && (p_ptr->vir_types[j] == p_ptr->vir_types[i]))
383                                 p_ptr->vir_types[j] = 0;
384                 }
385         }
386
387         /* Fill in the blanks */
388         for (i = 0; i < 8; i++)
389         {
390                 if (p_ptr->vir_types[i] == 0) get_random_virtue(i);
391         }
392 }
393
394 void chg_virtue(int virtue, int amount)
395 {
396         int i = 0;
397
398         for (i = 0; i < 8; i++)
399         {
400                 if (p_ptr->vir_types[i] == virtue)
401                 {
402                         if (amount > 0)
403                         {
404                                 if ((amount + p_ptr->virtues[i] > 50) && one_in_(2))
405                                 {
406                                         p_ptr->virtues[i] = MAX(p_ptr->virtues[i], 50);
407                                         return;
408                                 }
409                                 if ((amount + p_ptr->virtues[i] > 80) && one_in_(2))
410                                 {
411                                         p_ptr->virtues[i] = MAX(p_ptr->virtues[i], 80);
412                                         return;
413                                 }
414                                 if ((amount + p_ptr->virtues[i] > 100) && one_in_(2))
415                                 {
416                                         p_ptr->virtues[i] = MAX(p_ptr->virtues[i], 100);
417                                         return;
418                                 }
419                                 if (amount + p_ptr->virtues[i] > 125)
420                                         p_ptr->virtues[i] = 125;
421                                 else
422                                         p_ptr->virtues[i] = p_ptr->virtues[i] + amount;
423                         }
424                         else
425                         {
426                                 if ((amount + p_ptr->virtues[i] < -50) && one_in_(2))
427                                 {
428                                         p_ptr->virtues[i] = MIN(p_ptr->virtues[i], -50);
429                                         return;
430                                 }
431                                 if ((amount + p_ptr->virtues[i] < -80) && one_in_(2))
432                                 {
433                                         p_ptr->virtues[i] = MIN(p_ptr->virtues[i], -80);
434                                         return;
435                                 }
436                                 if ((amount + p_ptr->virtues[i] < -100) && one_in_(2))
437                                 {
438                                         p_ptr->virtues[i] = MIN(p_ptr->virtues[i], -100);
439                                         return;
440                                 }
441                                 if (amount + p_ptr->virtues[i] < -125)
442                                         p_ptr->virtues[i] = -125;
443                                 else
444                                         p_ptr->virtues[i] = p_ptr->virtues[i] + amount;
445                         }
446                         p_ptr->update |= (PU_BONUS);
447                         return;
448                 }
449         }
450 }
451
452 void set_virtue(int virtue, int amount)
453 {
454         int i = 0;
455
456         for (i = 0; i < 8; i++)
457         {
458                 if (p_ptr->vir_types[i] == virtue)
459                 {
460                         p_ptr->virtues[i] = amount;
461                         return;
462                 }
463         }
464 }
465
466 void dump_virtues(FILE *OutFile)
467 {
468         int v_nr = 0;
469
470         if (!OutFile) return;
471
472         for (v_nr = 0; v_nr < 8; v_nr++)
473         {
474                 char v_name [20];
475                 int tester = p_ptr->virtues[v_nr];
476
477                 strcpy(v_name, virtue[(p_ptr->vir_types[v_nr])-1]);
478
479                 if (p_ptr->vir_types[v_nr] == 0 || p_ptr->vir_types[v_nr] > MAX_VIRTUE)
480 #ifdef JP
481                         fprintf(OutFile, "¤ª¤Ã¤È¡£%s¤Î¾ðÊó¤Ê¤·¡£", v_name);
482 #else
483                         fprintf(OutFile, "Oops. No info about %s.", v_name);
484 #endif
485
486                 else if (tester < -100)
487 #ifdef JP
488                         fprintf(OutFile, "[%s]¤ÎÂжË",
489 #else
490                         fprintf(OutFile, "You are the polar opposite of %s.",
491 #endif
492
493                                 v_name);
494                 else if (tester < -80)
495 #ifdef JP
496                         fprintf(OutFile, "[%s]¤ÎÂçŨ",
497 #else
498                         fprintf(OutFile, "You are an arch-enemy of %s.",
499 #endif
500
501                                 v_name);
502                 else if (tester < -60)
503 #ifdef JP
504                         fprintf(OutFile, "[%s]¤Î¶¯Å¨",
505 #else
506                         fprintf(OutFile, "You are a bitter enemy of %s.",
507 #endif
508
509                                 v_name);
510                 else if (tester < -40)
511 #ifdef JP
512                         fprintf(OutFile, "[%s]¤ÎŨ",
513 #else
514                         fprintf(OutFile, "You are an enemy of %s.",
515 #endif
516
517                                 v_name);
518                 else if (tester < -20)
519 #ifdef JP
520                         fprintf(OutFile, "[%s]¤Îºá¼Ô",
521 #else
522                         fprintf(OutFile, "You have sinned against %s.",
523 #endif
524
525                                 v_name);
526                 else if (tester < 0)
527 #ifdef JP
528                         fprintf(OutFile, "[%s]¤ÎÌÂÆ»¼Ô",
529 #else
530                         fprintf(OutFile, "You have strayed from the path of %s.",
531 #endif
532
533                                 v_name);
534                 else if (tester == 0)
535 #ifdef JP
536                         fprintf(OutFile,"[%s]¤ÎÃæΩ¼Ô",
537 #else
538                         fprintf(OutFile,"You are neutral to %s.",
539 #endif
540
541                                 v_name);
542                 else if (tester < 20)
543 #ifdef JP
544                         fprintf(OutFile,"[%s]¤Î¾®ÆÁ¼Ô",
545 #else
546                         fprintf(OutFile,"You are somewhat virtuous in %s.",
547 #endif
548
549                                 v_name);
550                 else if (tester < 40)
551 #ifdef JP
552                         fprintf(OutFile,"[%s]¤ÎÃæÆÁ¼Ô",
553 #else
554                         fprintf(OutFile,"You are virtuous in %s.",
555 #endif
556
557                                 v_name);
558                 else if (tester < 60)
559 #ifdef JP
560                         fprintf(OutFile,"[%s]¤Î¹âÆÁ¼Ô",
561 #else
562                         fprintf(OutFile,"You are very virtuous in %s.",
563 #endif
564
565                                 v_name);
566                 else if (tester < 80)
567 #ifdef JP
568                         fprintf(OutFile,"[%s]¤ÎÇƼÔ",
569 #else
570                         fprintf(OutFile,"You are a champion of %s.",
571 #endif
572
573                                 v_name);
574                 else if (tester < 100)
575 #ifdef JP
576                         fprintf(OutFile,"[%s]¤Î°ÎÂç¤ÊÇƼÔ",
577 #else
578                         fprintf(OutFile,"You are a great champion of %s.",
579 #endif
580
581                                 v_name);
582                 else
583 #ifdef JP
584                         fprintf(OutFile,"[%s]¤Î¶ñ¸½¼Ô",
585 #else
586                         fprintf(OutFile,"You are the living embodiment of %s.",
587 #endif
588
589                                 v_name);
590
591             fprintf(OutFile, "\n");
592         }
593 }