• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision9c7238682d5a2a363be1767a4b4739a5e0675ed0 (tree)
Time2003-08-24 20:16:04
Authornothere <nothere@0568...>
Commiternothere

Log Message

フラグp_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell,
p_ptr->heavy_spellから導かれる魔法失敗率への影響を関数にまとめた. こ
れにより, 消費魔力減少のある魔道具術師の魔法道具使用失敗率が-1%になり
得たバグを修正.

Change Summary

Incremental Difference

--- a/src/cmd6.c
+++ b/src/cmd6.c
@@ -6999,11 +6999,7 @@ static int select_magic_eater(bool only_browse)
69996999 {
70007000 chance -= 3 * (p_ptr->lev - level);
70017001 }
7002- chance += p_ptr->to_m_chance;
7003- if (p_ptr->heavy_spell) chance += 20;
7004- if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
7005- else if (p_ptr->easy_spell) chance-=3;
7006- else if (p_ptr->dec_mana) chance-=2;
7002+ chance = mod_spell_chance_1(chance);
70077003 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
70087004 /* Stunning makes spells harder */
70097005 if (p_ptr->stun > 50) chance += 25;
@@ -7011,8 +7007,7 @@ static int select_magic_eater(bool only_browse)
70117007
70127008 if (chance > 95) chance = 95;
70137009
7014- if(p_ptr->dec_mana) chance--;
7015- if (p_ptr->heavy_spell) chance += 5;
7010+ chance = mod_spell_chance_2(chance);
70167011
70177012 col = TERM_WHITE;
70187013
@@ -7303,11 +7298,7 @@ msg_print("
73037298 {
73047299 chance -= 3 * (p_ptr->lev - level);
73057300 }
7306- chance += p_ptr->to_m_chance;
7307- if (p_ptr->heavy_spell) chance += 20;
7308- if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
7309- else if (p_ptr->easy_spell) chance-=3;
7310- else if (p_ptr->dec_mana) chance-=2;
7301+ chance = mod_spell_chance_1(chance);
73117302 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
73127303 /* Stunning makes spells harder */
73137304 if (p_ptr->stun > 50) chance += 25;
@@ -7315,8 +7306,7 @@ msg_print("
73157306
73167307 if (chance > 95) chance = 95;
73177308
7318- if(p_ptr->dec_mana) chance--;
7319- if (p_ptr->heavy_spell) chance += 5;
7309+ chance = mod_spell_chance_2(chance);
73207310
73217311 if (randint0(100) < chance)
73227312 {
--- a/src/externs.h
+++ b/src/externs.h
@@ -1130,6 +1130,8 @@ extern bool potion_smash_effect(int who, int y, int x, int k_idx);
11301130 extern void display_spell_list(void);
11311131 extern s16b experience_of_spell(int spell, int realm);
11321132 extern int mod_need_mana(int need_mana, int spell, int realm);
1133+extern int mod_spell_chance_1(int chance);
1134+extern int mod_spell_chance_2(int chance);
11331135 extern s16b spell_chance(int spell,int realm);
11341136 extern bool spell_okay(int spell, bool learned, bool study_pray, int realm);
11351137 extern void print_spells(int target_spell, byte *spells, int num, int y, int x, int realm);
--- a/src/mspells3.c
+++ b/src/mspells3.c
@@ -544,15 +544,10 @@ put_str("MP
544544 if (plev > spell.level) chance -= 3 * (plev - spell.level);
545545 else chance += (spell.level - plev);
546546
547- chance += p_ptr->to_m_chance;
548-
549547 /* Reduce failure rate by INT/WIS adjustment */
550548 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[A_INT]] - 1);
551549
552- if (p_ptr->heavy_spell) chance += 20;
553- if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
554- else if (p_ptr->easy_spell) chance-=3;
555- else if (p_ptr->dec_mana) chance-=2;
550+ chance = mod_spell_chance_1(chance);
556551
557552 need_mana = mod_need_mana(monster_powers[spellnum[i]].smana, 0, REALM_NONE);
558553
@@ -575,9 +570,7 @@ put_str("MP
575570 /* Always a 5 percent chance of working */
576571 if (chance > 95) chance = 95;
577572
578- if(p_ptr->dec_mana) chance--;
579- if (p_ptr->heavy_spell) chance += 5;
580- chance = MAX(chance,0);
573+ chance = mod_spell_chance_2(chance);
581574
582575 /* Get info */
583576 learned_info(comment, spellnum[i]);
@@ -1991,15 +1984,10 @@ if (!get_check("
19911984 if (plev > spell.level) chance -= 3 * (plev - spell.level);
19921985 else chance += (spell.level - plev);
19931986
1994- chance += p_ptr->to_m_chance;
1995-
19961987 /* Reduce failure rate by INT/WIS adjustment */
19971988 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[A_INT]] - 1);
19981989
1999- if (p_ptr->heavy_spell) chance += 20;
2000- if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
2001- else if (p_ptr->easy_spell) chance-=3;
2002- else if (p_ptr->dec_mana) chance-=2;
1990+ chance = mod_spell_chance_1(chance);
20031991
20041992 /* Not enough mana to cast */
20051993 if (need_mana > p_ptr->csp)
@@ -2020,9 +2008,7 @@ if (!get_check("
20202008 /* Always a 5 percent chance of working */
20212009 if (chance > 95) chance = 95;
20222010
2023- if(p_ptr->dec_mana) chance--;
2024- if (p_ptr->heavy_spell) chance += 5;
2025- chance = MAX(chance,0);
2011+ chance = mod_spell_chance_2(chance);
20262012
20272013 /* Failed spell */
20282014 if (randint0(100) < chance)
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -4140,6 +4140,39 @@ int mod_need_mana(int need_mana, int spell, int realm)
41404140
41414141
41424142 /*
4143+ * Modify spell fail rate
4144+ * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4145+ */
4146+int mod_spell_chance_1(int chance)
4147+{
4148+ chance += p_ptr->to_m_chance;
4149+
4150+ if (p_ptr->heavy_spell) chance += 20;
4151+
4152+ if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4153+ else if (p_ptr->easy_spell) chance -= 3;
4154+ else if (p_ptr->dec_mana) chance -= 2;
4155+
4156+ return chance;
4157+}
4158+
4159+
4160+/*
4161+ * Modify spell fail rate (as "suffix" process)
4162+ * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4163+ * Note: variable "chance" cannot be negative.
4164+ */
4165+int mod_spell_chance_2(int chance)
4166+{
4167+ if (p_ptr->dec_mana) chance--;
4168+
4169+ if (p_ptr->heavy_spell) chance += 5;
4170+
4171+ return MAX(chance, 0);
4172+}
4173+
4174+
4175+/*
41434176 * Returns spell chance of failure for spell -RAK-
41444177 */
41454178 s16b spell_chance(int spell, int use_realm)
@@ -4186,7 +4219,6 @@ s16b spell_chance(int spell, int use_realm)
41864219 chance += 5 * (need_mana - p_ptr->csp);
41874220 }
41884221
4189- chance += p_ptr->to_m_chance;
41904222 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
41914223
41924224 /* Extract the minimum failure rate */
@@ -4205,10 +4237,7 @@ s16b spell_chance(int spell, int use_realm)
42054237 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
42064238 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
42074239
4208- if (p_ptr->heavy_spell) chance += 20;
4209- if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4210- else if (p_ptr->easy_spell) chance-=3;
4211- else if (p_ptr->dec_mana) chance-=2;
4240+ chance = mod_spell_chance_1(chance);
42124241
42134242 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
42144243 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
@@ -4231,13 +4260,9 @@ s16b spell_chance(int spell, int use_realm)
42314260 if (exp >= SPELL_EXP_EXPERT) chance--;
42324261 if (exp >= SPELL_EXP_MASTER) chance--;
42334262 }
4234- if(p_ptr->dec_mana) chance--;
4235- if (p_ptr->heavy_spell) chance += 5;
4236-
4237- chance = MAX(chance,0);
42384263
42394264 /* Return the chance */
4240- return (chance);
4265+ return mod_spell_chance_2(chance);
42414266 }
42424267
42434268
Show on old repository browser