From 3c7096b82ded2871bc2c1ffa7106f1c8ae787f1b Mon Sep 17 00:00:00 2001 From: nothere Date: Sat, 3 May 2003 07:09:00 +0000 Subject: [PATCH] =?utf8?q?=E6=B6=88=E8=B2=BB=E9=AD=94=E5=8A=9B=E6=B8=9B?= =?utf8?q?=E5=B0=91=E3=83=95=E3=83=A9=E3=82=B0=E3=81=A8=20(=E9=A0=98?= =?utf8?q?=E5=9F=9F=E9=AD=94=E6=B3=95=E3=81=A7=E3=81=82=E3=82=8C=E3=81=B0)?= =?utf8?q?=20=E9=AD=94=E6=B3=95=E7=86=9F=E7=B7=B4=E5=BA=A6=E3=81=8B?= =?utf8?q?=E3=82=89=E5=B0=8E=E3=81=8B=E3=82=8C=E3=82=8B=E6=B6=88=E8=B2=BB?= =?utf8?q?=E9=AD=94=E5=8A=9B=E8=A8=88=E7=AE=97=E3=82=92=201=E9=96=A2?= =?utf8?q?=E6=95=B0=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81=E3=81=9F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd5.c | 70 +++++++++++++++++++++++++--------------------------------- src/dungeon.c | 43 +++++++++++++++++------------------- src/externs.h | 1 + src/mspells3.c | 35 +++++++++++------------------ src/spells3.c | 57 +++++++++++++++++++++++++++++------------------ 5 files changed, 100 insertions(+), 106 deletions(-) diff --git a/src/cmd5.c b/src/cmd5.c index c084160be..bcbb7dcf7 100644 --- a/src/cmd5.c +++ b/src/cmd5.c @@ -59,7 +59,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm int spell = -1; int num = 0; int ask = TRUE; - int shouhimana; + int need_mana; byte spells[64]; bool flag, redraw, okay; char choice; @@ -280,19 +280,14 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm s_ptr = &mp_ptr->info[use_realm - 1][spell]; } + /* Extract mana consumption rate */ if (use_realm == REALM_HISSATSU) { - shouhimana = s_ptr->smana; + need_mana = s_ptr->smana; } else { - /* Extract mana consumption rate */ - shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399; - if(p_ptr->dec_mana) - shouhimana *= 3; - else shouhimana *= 4; - shouhimana /= 9600; - if(shouhimana < 1) shouhimana = 1; + need_mana = mod_need_mana(s_ptr->smana, spell, use_realm); } /* Prompt */ @@ -300,11 +295,11 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm jverb1( prompt, jverb_buf ); /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */ (void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ", - spell_names[technic2magic(use_realm)-1][spell], shouhimana, + spell_names[technic2magic(use_realm)-1][spell], need_mana, spell_chance(spell, use_realm),jverb_buf); #else (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ", - prompt, spell_names[technic2magic(use_realm)-1][spell], shouhimana, + prompt, spell_names[technic2magic(use_realm)-1][spell], need_mana, spell_chance(spell, use_realm)); #endif @@ -4709,7 +4704,7 @@ void do_cmd_cast(void) int chance; int increment = 0; int use_realm; - int shouhimana; + int need_mana; bool cast; cptr prayer; @@ -4850,15 +4845,10 @@ s = " } /* Extract mana consumption rate */ - shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm)) + 2399; - if(p_ptr->dec_mana) - shouhimana *= 3; - else shouhimana *= 4; - shouhimana /= 9600; - if(shouhimana < 1) shouhimana = 1; + need_mana = mod_need_mana(s_ptr->smana, spell, realm); /* Verify "dangerous" spells */ - if (shouhimana > p_ptr->csp) + if (need_mana > p_ptr->csp) { if (flush_failure) flush(); @@ -5089,32 +5079,32 @@ msg_print("An infernal sound echoed."); switch (realm) { case REALM_LIFE: - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_TEMPERANCE, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_COMPASSION, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_VITALITY, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_DILIGENCE, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1); break; case REALM_DEATH: - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_UNLIFE, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_JUSTICE, -1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_FAITH, -1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_VITALITY, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1); break; case REALM_DAEMON: - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_JUSTICE, -1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_FAITH, -1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_HONOUR, -1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_TEMPERANCE, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1); break; case REALM_CRUSADE: - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_FAITH, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_JUSTICE, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_SACRIFICE, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_HONOUR, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1); break; case REALM_NATURE: - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_NATURE, 1); - if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_HARMONY, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1); + if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1); break; } if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP) @@ -5147,16 +5137,16 @@ msg_print("An infernal sound echoed."); energy_use = 100; /* Sufficient mana */ - if (shouhimana <= p_ptr->csp) + if (need_mana <= p_ptr->csp) { /* Use some mana */ - p_ptr->csp -= shouhimana; + p_ptr->csp -= need_mana; } /* Over-exert the player */ else { - int oops = shouhimana; + int oops = need_mana; /* No mana left */ p_ptr->csp = 0; diff --git a/src/dungeon.c b/src/dungeon.c index c987c6bc9..51504bc13 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1450,38 +1450,35 @@ static void recharged_notice(object_type *o_ptr) static void check_music(void) { magic_type *s_ptr; - u32b shouhimana; + int spell; + u32b need_mana; /* Music singed by player */ if(p_ptr->pclass != CLASS_BARD) return; if(!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return; - s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][p_ptr->magic_num2[0]]; + spell = p_ptr->magic_num2[0]; + s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell]; - shouhimana = (s_ptr->smana*(3800-p_ptr->spell_exp[p_ptr->magic_num2[0]])+2399); - if(p_ptr->dec_mana) - shouhimana *= 3; - else shouhimana *= 4; - shouhimana /= 9600; - if(shouhimana < 1) shouhimana = 1; - shouhimana *= 0x8000; - if (((u16b)(p_ptr->csp) < (shouhimana / 0x10000)) || (p_ptr->anti_magic)) + need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC); + need_mana *= 0x8000; + if (((u16b)(p_ptr->csp) < (need_mana / 0x10000)) || (p_ptr->anti_magic)) { stop_singing(); return; } else { - p_ptr->csp -= (u16b) (shouhimana / 0x10000); - shouhimana = (shouhimana & 0xffff); - if (p_ptr->csp_frac < shouhimana) + p_ptr->csp -= (u16b) (need_mana / 0x10000); + need_mana = (need_mana & 0xffff); + if (p_ptr->csp_frac < need_mana) { p_ptr->csp--; - p_ptr->csp_frac += (u16b)(0x10000L - shouhimana); + p_ptr->csp_frac += (u16b)(0x10000L - need_mana); } else { - p_ptr->csp_frac -= (u16b)shouhimana; + p_ptr->csp_frac -= (u16b)need_mana; } p_ptr->redraw |= PR_MANA; @@ -1503,14 +1500,14 @@ static void check_music(void) p_ptr->redraw |= (PR_STATUS); } } - if (p_ptr->spell_exp[p_ptr->magic_num2[0]] < 900) - p_ptr->spell_exp[p_ptr->magic_num2[0]]+=5; - else if(p_ptr->spell_exp[p_ptr->magic_num2[0]] < 1200) - {if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[p_ptr->magic_num2[0]]+=1;} - else if(p_ptr->spell_exp[p_ptr->magic_num2[0]] < 1400) - {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[p_ptr->magic_num2[0]]+=1;} - else if(p_ptr->spell_exp[p_ptr->magic_num2[0]] < 1600) - {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[p_ptr->magic_num2[0]]+=1;} + if (p_ptr->spell_exp[spell] < 900) + p_ptr->spell_exp[spell]+=5; + else if(p_ptr->spell_exp[spell] < 1200) + {if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell]+=1;} + else if(p_ptr->spell_exp[spell] < 1400) + {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell]+=1;} + else if(p_ptr->spell_exp[spell] < 1600) + {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell]+=1;} gere_music(p_ptr->magic_num1[0]); } diff --git a/src/externs.h b/src/externs.h index e6d1fd8e7..305e76247 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1101,6 +1101,7 @@ extern bool pulish_shield(void); extern bool potion_smash_effect(int who, int y, int x, int k_idx); extern void display_spell_list(void); extern s16b experience_of_spell(int spell, int realm); +extern int mod_need_mana(int need_mana, int spell, int realm); extern s16b spell_chance(int spell,int realm); extern bool spell_okay(int spell, bool learned, bool study_pray, int realm); extern void print_spells(int target_spell, byte *spells, int num, int y, int x, int realm); diff --git a/src/mspells3.c b/src/mspells3.c index 849965cf8..d286ae00d 100644 --- a/src/mspells3.c +++ b/src/mspells3.c @@ -560,7 +560,7 @@ put_str("MP /* Dump the spells */ for (i = 0; i < num; i++) { - int shouhimana; + int need_mana; prt("", y + i + 1, x); if (!p_ptr->magic_num2[spellnum[i]]) continue; @@ -584,16 +584,12 @@ put_str("MP else if (p_ptr->easy_spell) chance-=3; else if (p_ptr->dec_mana) chance-=2; - shouhimana = monster_powers[spellnum[i]].smana; - if (p_ptr->dec_mana) - { - shouhimana = (shouhimana + 1) * 3 / 4; - } + need_mana = mod_need_mana(monster_powers[spellnum[i]].smana, 0, REALM_NONE); /* Not enough mana to cast */ - if (shouhimana > p_ptr->csp) + if (need_mana > p_ptr->csp) { - chance += 5 * (shouhimana - p_ptr->csp); + chance += 5 * (need_mana - p_ptr->csp); } /* Extract the minimum failure rate */ @@ -629,7 +625,7 @@ put_str("MP /* Dump the spell --(-- */ strcat(psi_desc, format(" %-26s %3d %3d%%%s", - spell.name, shouhimana, + spell.name, need_mana, chance, comment)); prt(psi_desc, y + i + 1, x); } @@ -1989,7 +1985,7 @@ bool do_cmd_cast_learned(void) int plev = p_ptr->lev; monster_power spell; bool cast; - int shouhimana; + int need_mana; /* not if confused */ @@ -2009,15 +2005,10 @@ msg_print(" spell = monster_powers[n]; - shouhimana = spell.smana; - - if (p_ptr->dec_mana) - { - shouhimana = (shouhimana + 1) * 3 / 4; - } + need_mana = mod_need_mana(spell.smana, 0, REALM_NONE); /* Verify "dangerous" spells */ - if (shouhimana > p_ptr->csp) + if (need_mana > p_ptr->csp) { /* Warning */ #ifdef JP @@ -2056,9 +2047,9 @@ if (!get_check(" else if (p_ptr->dec_mana) chance-=2; /* Not enough mana to cast */ - if (shouhimana > p_ptr->csp) + if (need_mana > p_ptr->csp) { - chance += 5 * (shouhimana - p_ptr->csp); + chance += 5 * (need_mana - p_ptr->csp); } /* Extract the minimum failure rate */ @@ -2105,14 +2096,14 @@ msg_print(" } /* Sufficient mana */ - if (shouhimana <= p_ptr->csp) + if (need_mana <= p_ptr->csp) { /* Use some mana */ - p_ptr->csp -= shouhimana; + p_ptr->csp -= need_mana; } else { - int oops = shouhimana; + int oops = need_mana; /* No mana left */ p_ptr->csp = 0; diff --git a/src/spells3.c b/src/spells3.c index 1a75e9f81..9683e6e51 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -3906,13 +3906,40 @@ s16b experience_of_spell(int spell, int use_realm) /* + * Modify mana consumption rate using spell exp and p_ptr->dec_mana + */ +int mod_need_mana(int need_mana, int spell, int realm) +{ + /* Realm magic */ + if ((realm > REALM_NONE) && (realm <= MAX_REALM)) + { + need_mana = need_mana * (3800 - experience_of_spell(spell, realm)) + 2399; + + if (p_ptr->dec_mana) need_mana *= 3; + else need_mana *= 4; + + need_mana /= 9600; + if (need_mana < 1) need_mana = 1; + } + + /* Non-realm magic */ + else + { + if (p_ptr->dec_mana) need_mana = (need_mana + 1) * 3 / 4; + } + + return need_mana; +} + + +/* * Returns spell chance of failure for spell -RAK- */ s16b spell_chance(int spell, int use_realm) { int chance, minfail; magic_type *s_ptr; - int shouhimana; + int need_mana; int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4; @@ -3944,18 +3971,12 @@ s16b spell_chance(int spell, int use_realm) chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level-p_ptr->skill_exp[GINOU_RIDING]/100-10,0)); /* Extract mana consumption rate */ - shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399; - - if(p_ptr->dec_mana) shouhimana *= 3; - else shouhimana *= 4; - - shouhimana /= 9600; - if(shouhimana < 1) shouhimana = 1; + need_mana = mod_need_mana(s_ptr->smana, spell, use_realm); /* Not enough mana to cast */ - if (shouhimana > p_ptr->csp) + if (need_mana > p_ptr->csp) { - chance += 5 * (shouhimana - p_ptr->csp); + chance += 5 * (need_mana - p_ptr->csp); } chance += p_ptr->to_m_chance; @@ -4404,7 +4425,7 @@ void print_spells(int target_spell, byte *spells, int num, int y, int x, int use char info[80]; char out_val[160]; byte line_attr; - int shouhimana; + int need_mana; char ryakuji[5]; char buf[256]; bool max = FALSE; @@ -4462,19 +4483,13 @@ put_str(buf, y, x + 29); } if (use_realm == REALM_HISSATSU) - shouhimana = s_ptr->smana; + need_mana = s_ptr->smana; else { s16b exp = experience_of_spell(spell, use_realm); /* Extract mana consumption rate */ - shouhimana = s_ptr->smana*(3800 - exp) + 2399; - - if(p_ptr->dec_mana) shouhimana *= 3; - else shouhimana *= 4; - - shouhimana /= 9600; - if(shouhimana < 1) shouhimana = 1; + need_mana = mod_need_mana(s_ptr->smana, spell, use_realm); if ((increment == 64) || (s_ptr->slevel >= 99)) shougou = 0; else if (exp < 900) shougou = 0; @@ -4606,14 +4621,14 @@ comment = " ̤ { strcat(out_val, format("%-25s %2d %4d", spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */ - s_ptr->slevel, shouhimana)); + s_ptr->slevel, need_mana)); } else { strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s", spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */ (max ? '!' : ' '), ryakuji, - s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment)); + s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment)); } c_prt(line_attr, out_val, y + i + 1, x); } -- 2.11.0