static void _list_spell(doc_ptr doc, int realm, int spell, int choice, int options) { magic_type *spell_ptr = _get_spell_info(realm, spell); int cost = calculate_cost(spell_ptr->smana); int fail = calculate_fail_rate(spell_ptr->slevel, spell_ptr->sfail, p_ptr->stat_ind[A_INT]); if (cost > p_ptr->csp) doc_insert(doc, "<color:D>"); else if (choice == _browse_choice) doc_insert(doc, "<color:B>"); else if (spell_ptr->slevel > p_ptr->lev) { if (options & _FROM_BOOK) doc_insert(doc, "<color:D>"); else doc_insert(doc, "<color:y>"); } else doc_insert(doc, "<color:w>"); if (spell_ptr->slevel > p_ptr->lev) doc_printf(doc, " <color:D>%c)</color> ", I2A(choice)); else doc_printf(doc, " %c) ", I2A(choice)); doc_printf(doc, "%-20.20s ", do_spell(realm, spell, SPELL_NAME)); doc_printf(doc, "%3d %3d %3d%% ", spell_ptr->slevel, cost, fail); if (spell_ptr->slevel > p_ptr->lev) { if (options & _FROM_BOOK) doc_printf(doc, "%-15.15s", ""); else doc_printf(doc, "%-15.15s", "Forgotten"); } else if (options & _SHOW_INFO) doc_printf(doc, "%-15.15s", do_spell(realm, spell, SPELL_INFO)); if (options & _SHOW_STATS) { spell_stats_ptr stats = spell_stats_old(realm, spell); if (stats->ct_cast + stats->ct_fail) { doc_printf(doc, " %5d %4d %3d%%", stats->ct_cast, stats->ct_fail, spell_stats_fail(stats) ); } } doc_insert(doc, "</color>\n"); }
void dump_spells_aux(FILE *fff, spell_info *table, int ct) { int i; variant vn, vd, vc, vfm; if (!ct) return; var_init(&vn); var_init(&vd); var_init(&vc); var_init(&vfm); if (character_dump_hack) { fprintf(fff, "=================================== Spells ====================================\n\n"); fprintf(fff, "%-20.20s Lvl Cost Fail %-15.15s Cast Fail\n", "", "Desc"); } else { fprintf(fff, "\n[[[[r|%-20.20s Lvl Cost Fail %-15.15s Cast Fail\n", "Spells", "Desc"); } for (i = 0; i < ct; i++) { spell_info *spell = &table[i]; spell_stats_ptr stats = spell_stats(spell); spell->fn(SPELL_NAME, &vn); spell->fn(SPELL_INFO, &vd); spell->fn(SPELL_COST_EXTRA, &vc); spell->fn(SPELL_FAIL_MIN, &vfm); fprintf(fff, "%-20.20s %3d %4d %3d%% %-15.15s %4d %4d %3d%%\n", var_get_string(&vn), spell->level, calculate_cost(spell->cost + var_get_int(&vc)), MAX(spell->fail, var_get_int(&vfm)), var_get_string(&vd), stats->ct_cast, stats->ct_fail, spell_stats_fail(stats) ); } var_clear(&vn); var_clear(&vd); var_clear(&vc); var_clear(&vfm); }
static void _dump_book(doc_ptr doc, int realm, int book) { int k_idx = lookup_kind(realm2tval(realm), book); int i, increment = 64; caster_info *caster_ptr = get_caster_info(); if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0; else if (realm == p_ptr->realm1) increment = 0; else if (realm == p_ptr->realm2) increment = 32; if (realm == REALM_HISSATSU) { doc_printf(doc, "<color:G> %-25.25s Lvl SP %-15.15s Cast</color>\n", k_name + k_info[k_idx].name, "Desc"); } else { if (caster_ptr && (caster_ptr->options & CASTER_USE_HP)) doc_printf(doc, "<color:G> %-23.23s Profic Lvl HP Fail %-15.15s Cast Fail</color>\n", k_name + k_info[k_idx].name, "Desc"); else doc_printf(doc, "<color:G> %-23.23s Profic Lvl SP Fail %-15.15s Cast Fail</color>\n", k_name + k_info[k_idx].name, "Desc"); } for (i = 0; i < 8; i++) { int s_idx = book * 8 + i; magic_type *s_ptr; int cost; bool max = FALSE; char proficiency[10]; char info[80]; cptr comment; char line[160]; char color = 'w'; if (is_magic(realm)) s_ptr = &mp_ptr->info[realm - 1][s_idx]; else s_ptr = &technic_info[realm - MIN_TECHNIC][s_idx]; if (s_ptr->slevel >= 99) continue; if (realm == REALM_HISSATSU) cost = s_ptr->smana; else { s16b exp = experience_of_spell(s_idx, realm); int exp_level = spell_exp_level(exp); cost = mod_need_mana(s_ptr->smana, s_idx, realm); max = FALSE; if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE; else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE; else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE; strncpy(proficiency, exp_level_str[exp_level], 4); proficiency[3] = ']'; proficiency[4] = '\0'; } strcpy(info, do_spell(realm, s_idx, SPELL_INFO)); comment = info; if (p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_RED_MAGE) { if (s_ptr->slevel > p_ptr->max_plv) { comment = "unknown"; color = 'D'; } else if (s_ptr->slevel > p_ptr->lev) { comment = "forgotten"; color = 'y'; } } else if ((realm == p_ptr->realm1) ? ((p_ptr->spell_forgotten1 & (1L << s_idx))) : ((p_ptr->spell_forgotten2 & (1L << s_idx)))) { comment = "forgotten"; color = 'y'; } else if (!((realm == p_ptr->realm1) ? (p_ptr->spell_learned1 & (1L << s_idx)) : (p_ptr->spell_learned2 & (1L << s_idx)))) { comment = "unknown"; if (s_ptr->slevel > p_ptr->lev) color = 'D'; else color = 'B'; } else if (!((realm == p_ptr->realm1) ? (p_ptr->spell_worked1 & (1L << s_idx)) : (p_ptr->spell_worked2 & (1L << s_idx)))) { comment = "untried"; } sprintf(line, " %c) ", I2A(i)); if (realm == REALM_HISSATSU) { spell_stats_ptr stats = spell_stats_old(realm, s_idx); strcat( line, format( "<color:%c>%-25s %3d %3d %-15.15s %5d</color>", color, do_spell(realm, s_idx, SPELL_NAME), s_ptr->slevel, cost, comment, stats->ct_cast ) ); } else { spell_stats_ptr stats = spell_stats_old(realm, s_idx); strcat( line, format( "<color:%c>%-25s%c%-4s %3d %3d %3d%% %-15.15s %5d %4d %3d%%</color>", color, do_spell(realm, s_idx, SPELL_NAME), (max ? '!' : ' '), proficiency, s_ptr->slevel, cost, spell_chance(s_idx, realm), comment, stats->ct_cast, stats->ct_fail, spell_stats_fail(stats) ) ); } doc_printf(doc, "%s\n", line); } doc_newline(doc); }