if (repeat_pull(sn))
{
/* Verify the spell */
- if (spell_okay(*sn, learned, FALSE, use_realm - 1))
+ if (spell_okay(*sn, learned, FALSE, use_realm))
{
/* Success */
return (TRUE);
for (i = 0; i < num; i++)
{
/* Look for "okay" spells */
- if (spell_okay(spells[i], learned, FALSE, use_realm - 1)) okay = TRUE;
+ if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
}
/* No "okay" spells */
}
if (menu_line > num) menu_line -= num;
/* Display a list of spells */
- print_spells(menu_line, spells, num, 1, 15, use_realm - 1);
+ print_spells(menu_line, spells, num, 1, 15, use_realm);
if (ask) continue;
}
else
screen_save();
/* Display a list of spells */
- print_spells(menu_line, spells, num, 1, 15, use_realm - 1);
+ print_spells(menu_line, spells, num, 1, 15, use_realm);
}
/* Hide the list */
spell = spells[i];
/* Require "okay" spells */
- if (!spell_okay(spell, learned, FALSE, use_realm - 1))
+ if (!spell_okay(spell, learned, FALSE, use_realm))
{
bell();
#ifdef JP
/* Access the spell */
if (!is_magic(use_realm))
{
- s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+ s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
}
else
{
else
{
/* Extract mana consumption rate */
- shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm-1)) + 2399;
+ shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
if(p_ptr->dec_mana)
shouhimana *= 3;
else shouhimana *= 4;
/* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
(void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
spell_names[technic2magic(use_realm)-1][spell % 32], shouhimana,
- spell_chance(spell, use_realm -1),jverb_buf);
+ 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 % 32], shouhimana,
- spell_chance(spell, use_realm - 1));
+ spell_chance(spell, use_realm));
#endif
if (spell == -1) break;
/* Display a list of spells */
- print_spells(0, spells, num, 1, 15, use_realm - 1);
+ print_spells(0, spells, num, 1, 15, use_realm);
/* Notify that there's nothing to see, and wait. */
if (use_realm == REALM_HISSATSU)
/* Access the spell */
if (!is_magic(use_realm))
{
- s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+ s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
}
else
{
{
/* Skip non "okay" prayers */
if (!spell_okay(spell, FALSE, TRUE,
- (increment ? p_ptr->realm2 - 1 : p_ptr->realm1 - 1))) continue;
+ (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
/* Hack -- Prepare the randomizer */
k++;
if (!is_magic(use_realm))
{
- s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+ s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
}
else
{
}
/* Extract mana consumption rate */
- shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm-1)) + 2399;
+ shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm)) + 2399;
if(p_ptr->dec_mana)
shouhimana *= 3;
else shouhimana *= 4;
/* Spell failure chance */
- chance = spell_chance(spell, use_realm - 1);
+ chance = spell_chance(spell, use_realm);
/* Failed spell */
if (randint0(100) < chance)
{
int i, j;
int y, x;
- int use_realm1 = p_ptr->realm1 - 1;
- int use_realm2 = p_ptr->realm2 - 1;
int m[9];
magic_type *s_ptr;
char name[80];
/* Normal spellcaster with books */
/* Scan books */
- for (j = 0; j < ((use_realm2 > -1) ? 2 : 1); j++)
+ for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
{
int n = 0;
byte a = TERM_WHITE;
/* Access the spell */
- if (!is_magic((j < 1) ? use_realm1 : use_realm2))
+ if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
{
- s_ptr = &technic_info[(j < 1) ? use_realm1 : use_realm2 - MIN_TECHNIC][i % 32];
+ s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
}
else
{
- s_ptr = &mp_ptr->info[(j < 1) ? use_realm1 : use_realm2][i % 32];
+ s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
}
- strcpy(name, spell_names[technic2magic((j < 1) ? use_realm1+1 : use_realm2+1)-1][i % 32]);
+ strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
/* Illegible */
if (s_ptr->slevel >= 99)
/*
* Returns experience of a spell
*/
-s16b experience_of_spell(int spell, int realm)
+s16b experience_of_spell(int spell, int use_realm)
{
if (p_ptr->pclass == CLASS_SORCERER) return 1600;
else if (p_ptr->pclass == CLASS_RED_MAGE) return 1200;
- else if (realm+1 == p_ptr->realm1) return p_ptr->spell_exp[spell];
- else if (realm+1 == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
+ else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
+ else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
else return 0;
}
/*
* Returns spell chance of failure for spell -RAK-
*/
-s16b spell_chance(int spell, int realm)
+s16b spell_chance(int spell, int use_realm)
{
int chance, minfail;
magic_type *s_ptr;
/* Paranoia -- must be literate */
if (!mp_ptr->spell_book) return (100);
- if (realm+1 == REALM_HISSATSU) return 0;
+ if (use_realm == REALM_HISSATSU) return 0;
/* Access the spell */
- if (!is_magic(realm+1))
+ if (!is_magic(use_realm))
{
- s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+ s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
}
else
{
- s_ptr = &mp_ptr->info[realm][spell];
+ s_ptr = &mp_ptr->info[use_realm - 1][spell];
}
/* Extract the base spell failure rate */
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, realm)) + 2399;
+ shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
if(p_ptr->dec_mana) shouhimana *= 3;
else shouhimana *= 4;
}
chance += p_ptr->to_m_chance;
- if (((realm + 1) != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
+ if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
/* Extract the minimum failure rate */
minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
else if (p_ptr->easy_spell) chance-=3;
else if (p_ptr->dec_mana) chance-=2;
- if ((realm+1 == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
- if (((realm+1 == REALM_LIFE) || (realm+1 == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
- if (((realm+1 == REALM_DEATH) || (realm+1 == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
+ if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
+ if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
+ if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
/* Minimum failure rate */
if (chance < minfail) chance = minfail;
/* Always a 5 percent chance of working */
if (chance > 95) chance = 95;
- if ((realm+1 == p_ptr->realm1) || (realm+1 == p_ptr->realm2))
+ if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2))
{
- s16b exp = experience_of_spell(spell, realm);
+ s16b exp = experience_of_spell(spell, use_realm);
if(exp > 1399) chance--;
if(exp > 1599) chance--;
}
* The spell must be legible, not forgotten, and also, to cast,
* it must be known, and to study, it must not be known.
*/
-bool spell_okay(int spell, bool learned, bool study_pray, int realm)
+bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
{
magic_type *s_ptr;
/* Access the spell */
- if (!is_magic(realm+1))
+ if (!is_magic(use_realm))
{
- s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+ s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
}
else
{
- s_ptr = &mp_ptr->info[realm][spell];
+ s_ptr = &mp_ptr->info[use_realm - 1][spell];
}
/* Spell is illegal */
if (s_ptr->slevel > p_ptr->lev) return (FALSE);
/* Spell is forgotten */
- if ((realm == p_ptr->realm2 - 1) ?
+ if ((use_realm == p_ptr->realm2) ?
(p_ptr->spell_forgotten2 & (1L << spell)) :
(p_ptr->spell_forgotten1 & (1L << spell)))
{
if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
/* Spell is learned */
- if ((realm == p_ptr->realm2 - 1) ?
+ if ((use_realm == p_ptr->realm2) ?
(p_ptr->spell_learned2 & (1L << spell)) :
(p_ptr->spell_learned1 & (1L << spell)))
{
* The strings in this function were extracted from the code in the
* functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
*/
-static void spell_info(char *p, int spell, int realm)
+static void spell_info(char *p, int spell, int use_realm)
{
int plev = p_ptr->lev;
strcpy(p, "");
/* Analyze the spell */
- switch (realm)
+ switch (use_realm)
{
- case 0: /* Life */
+ case REALM_LIFE: /* Life */
switch (spell)
{
case 0: sprintf(p, " %s2d10", s_heal); break;
}
break;
- case 1: /* Sorcery */
+ case REALM_SORCERY: /* Sorcery */
switch (spell)
{
case 1: sprintf(p, " %s10", s_range); break;
}
break;
- case 2: /* Nature */
+ case REALM_NATURE: /* Nature */
switch (spell)
{
#ifdef JP
}
break;
- case 3: /* Chaos */
+ case REALM_CHAOS: /* Chaos */
switch (spell)
{
case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
}
break;
- case 4: /* Death */
+ case REALM_DEATH: /* Death */
switch (spell)
{
case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
}
break;
- case 5: /* Trump */
+ case REALM_TRUMP: /* Trump */
switch (spell)
{
case 0: sprintf(p, " %s10", s_range); break;
}
break;
- case 6: /* Arcane */
+ case REALM_ARCANE: /* Arcane */
switch (spell)
{
case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
}
break;
- case 7: /* Craft */
+ case REALM_ENCHANT: /* Craft */
switch (spell)
{
case 0: sprintf(p, " %s100+d100", s_dur); break;
}
break;
- case 8: /* Daemon */
+ case REALM_DAEMON: /* Daemon */
switch (spell)
{
case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
}
break;
- case 9: /* Crusade */
+ case REALM_CRUSADE: /* Crusade */
switch (spell)
{
case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
}
break;
- case 15: /* Music */
+ case REALM_MUSIC: /* Music */
switch (spell)
{
case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
break;
default:
#ifdef JP
- sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", realm);
+ sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
#else
- sprintf(p, "Unknown type: %d.", realm);
+ sprintf(p, "Unknown type: %d.", use_realm);
#endif
}
}
/*
* Print a list of spells (for browsing or casting or viewing)
*/
-void print_spells(int target_spell, byte *spells, int num, int y, int x, int realm)
+void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
{
int i, spell, shougou, increment = 64;
magic_type *s_ptr;
bool max = FALSE;
- if (((realm < 0) || (realm > MAX_REALM - 1)) && p_ptr->wizard)
+ if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
#ifdef JP
msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
#else
/* Title the list */
prt("", y, x);
- if (realm+1 == REALM_HISSATSU)
+ if (use_realm == REALM_HISSATSU)
#ifdef JP
strcpy(buf," Lv MP");
#else
#endif
if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
- else if ((realm + 1) == p_ptr->realm1) increment = 0;
- else if ((realm + 1) == p_ptr->realm2) increment = 32;
+ else if (use_realm == p_ptr->realm1) increment = 0;
+ else if (use_realm == p_ptr->realm2) increment = 32;
/* Dump the spells */
for (i = 0; i < num; i++)
spell = spells[i];
/* Access the spell */
- if (!is_magic(realm+1))
+ if (!is_magic(use_realm))
{
- s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+ s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
}
else
{
- s_ptr = &mp_ptr->info[realm][spell];
+ s_ptr = &mp_ptr->info[use_realm - 1][spell];
}
- if (realm+1 == REALM_HISSATSU)
+ if (use_realm == REALM_HISSATSU)
shouhimana = s_ptr->smana;
else
{
- s16b exp = experience_of_spell(spell, realm);
+ s16b exp = experience_of_spell(spell, use_realm);
/* Extract mana consumption rate */
shouhimana = s_ptr->smana*(3800 - exp) + 2399;
/* XXX XXX Could label spells above the players level */
/* Get extra info */
- spell_info(info, spell, realm);
+ spell_info(info, spell, use_realm);
/* Use that info */
comment = info;
line_attr = TERM_YELLOW;
}
}
- else if ((realm+1 != p_ptr->realm1) && (realm+1 != p_ptr->realm2))
+ else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
{
#ifdef JP
comment = " ̤ÃÎ";
line_attr = TERM_L_BLUE;
}
- else if ((realm + 1 == p_ptr->realm1) ?
+ else if ((use_realm == p_ptr->realm1) ?
((p_ptr->spell_forgotten1 & (1L << spell))) :
((p_ptr->spell_forgotten2 & (1L << spell))))
{
line_attr = TERM_YELLOW;
}
- else if (!((realm + 1 == p_ptr->realm1) ?
+ else if (!((use_realm == p_ptr->realm1) ?
(p_ptr->spell_learned1 & (1L << spell)) :
(p_ptr->spell_learned2 & (1L << spell))))
{
line_attr = TERM_L_BLUE;
}
- else if (!((realm + 1 == p_ptr->realm1) ?
+ else if (!((use_realm == p_ptr->realm1) ?
(p_ptr->spell_worked1 & (1L << spell)) :
(p_ptr->spell_worked2 & (1L << spell))))
{
}
/* Dump the spell --(-- */
- if (realm+1 == REALM_HISSATSU)
+ if (use_realm == REALM_HISSATSU)
{
strcat(out_val, format("%-25s %2d %4d",
- spell_names[technic2magic(realm+1)-1][spell], /* realm, spell */
+ spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
s_ptr->slevel, shouhimana));
}
else
{
strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
- spell_names[technic2magic(realm+1)-1][spell], /* realm, spell */
+ spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
(max ? '!' : ' '), ryakuji,
- s_ptr->slevel, shouhimana, spell_chance(spell, realm), comment));
+ s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment));
}
c_prt(line_attr, out_val, y + i + 1, x);
}
int num_boukyaku = 0;
magic_type *s_ptr;
- int use_realm1 = p_ptr->realm1 - 1;
- int use_realm2 = p_ptr->realm2 - 1;
int which;
int bonus = 0;
/* Get the spell */
- if (!is_magic(((j < 32) ? use_realm1 : use_realm2)+1))
+ if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
{
if (j < 32)
- s_ptr = &technic_info[use_realm1 - MIN_TECHNIC][j];
+ s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
else
- s_ptr = &technic_info[use_realm2 - MIN_TECHNIC][j%32];
+ s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
}
else if (j < 32)
- s_ptr = &mp_ptr->info[use_realm1][j];
+ s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
else
- s_ptr = &mp_ptr->info[use_realm2][j%32];
+ s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
/* Skip spells we are allowed to know */
if (s_ptr->slevel <= p_ptr->lev) continue;
if (j < 32)
{
p_ptr->spell_forgotten1 |= (1L << j);
- which = use_realm1;
+ which = p_ptr->realm1;
}
else
{
p_ptr->spell_forgotten2 |= (1L << (j - 32));
- which = use_realm2;
+ which = p_ptr->realm2;
}
/* No longer known */
if (j < 32)
{
p_ptr->spell_learned1 &= ~(1L << j);
- which = use_realm1;
+ which = p_ptr->realm1;
}
else
{
p_ptr->spell_learned2 &= ~(1L << (j - 32));
- which = use_realm2;
+ which = p_ptr->realm2;
}
/* Message */
#ifdef JP
msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
- spell_names[technic2magic(which+1)-1][j%32], p );
+ spell_names[technic2magic(which)-1][j%32], p );
#else
msg_format("You have forgotten the %s of %s.", p,
- spell_names[technic2magic(which+1)-1][j%32]);
+ spell_names[technic2magic(which)-1][j%32]);
#endif
if (j < 32)
{
p_ptr->spell_forgotten1 |= (1L << j);
- which = use_realm1;
+ which = p_ptr->realm1;
}
else
{
p_ptr->spell_forgotten2 |= (1L << (j - 32));
- which = use_realm2;
+ which = p_ptr->realm2;
}
/* No longer known */
if (j < 32)
{
p_ptr->spell_learned1 &= ~(1L << j);
- which = use_realm1;
+ which = p_ptr->realm1;
}
else
{
p_ptr->spell_learned2 &= ~(1L << (j - 32));
- which = use_realm2;
+ which = p_ptr->realm2;
}
/* Message */
#ifdef JP
msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
- spell_names[technic2magic(which+1)-1][j%32], p );
+ spell_names[technic2magic(which)-1][j%32], p );
#else
msg_format("You have forgotten the %s of %s.", p,
- spell_names[technic2magic(which+1)-1][j%32]);
+ spell_names[technic2magic(which)-1][j%32]);
#endif
if (j >= 99) break;
/* Access the spell */
- if (!is_magic(((j < 32) ? use_realm1 : use_realm2)+1))
+ if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
{
if (j < 32)
- s_ptr = &technic_info[use_realm1 - MIN_TECHNIC][j];
+ s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
else
- s_ptr = &technic_info[use_realm2 - MIN_TECHNIC][j%32];
+ s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
}
else if (j<32)
- s_ptr = &mp_ptr->info[use_realm1][j];
+ s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
else
- s_ptr = &mp_ptr->info[use_realm2][j%32];
+ s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
/* Skip spells we cannot remember */
if (s_ptr->slevel > p_ptr->lev) continue;
if (j < 32)
{
p_ptr->spell_forgotten1 &= ~(1L << j);
- which = use_realm1;
+ which = p_ptr->realm1;
}
else
{
p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
- which = use_realm2;
+ which = p_ptr->realm2;
}
/* Known once more */
if (j < 32)
{
p_ptr->spell_learned1 |= (1L << j);
- which = use_realm1;
+ which = p_ptr->realm1;
}
else
{
p_ptr->spell_learned2 |= (1L << (j - 32));
- which = use_realm2;
+ which = p_ptr->realm2;
}
/* Message */
#ifdef JP
msg_format("%s¤Î%s¤ò»×¤¤½Ð¤·¤¿¡£",
- spell_names[technic2magic(which+1)-1][j%32], p );
+ spell_names[technic2magic(which)-1][j%32], p );
#else
msg_format("You have remembered the %s of %s.",
- p, spell_names[technic2magic(which+1)-1][j%32]);
+ p, spell_names[technic2magic(which)-1][j%32]);
#endif
/* Count spells that can be learned */
for (j = 0; j < 32; j++)
{
- if (!is_magic(use_realm1+1)) s_ptr = &technic_info[use_realm1-MIN_TECHNIC][j];
- else s_ptr = &mp_ptr->info[use_realm1][j];
+ if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1-MIN_TECHNIC][j];
+ else s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
/* Skip spells we cannot remember */
if (s_ptr->slevel > p_ptr->lev) continue;