Ejemplo n.º 1
0
void skills_innate_gain(cptr name)
{
    _skill_info_ptr info = _innate_info(name);

    /* Double Check initialization */
    if (!info)
    {
        info = malloc(sizeof(_skill_info_t));
        info->current = WEAPON_EXP_UNSKILLED;
        info->max = WEAPON_EXP_MASTER;
        str_map_add(_innate_map(), name, info);
    }

    if (info->current < info->max)
    {
        int add = 0;

        if (info->current < WEAPON_EXP_BEGINNER) add = 80;
        else if (info->current < WEAPON_EXP_SKILLED) add = 10;
        else if (info->current < WEAPON_EXP_EXPERT && p_ptr->lev > 19) add = 1;
        else if (p_ptr->lev > 34 && one_in_(2)) add = 1;

        if (add > 0)
        {
            int old_bonus = _innate_calc_bonus_aux(info->current);
            int new_bonus;
            info->current += add;
            if (info->current > info->max)
                info->current = info->max;
            new_bonus = _innate_calc_bonus_aux(info->current);
            if (old_bonus != new_bonus)
                p_ptr->update |= PU_BONUS;
        }
    }
}
Ejemplo n.º 2
0
void spell_stats_on_load(savefile_ptr file)
{
    str_map_ptr map = _spell_stats_map();
    int         ct, i;

    str_map_clear(map);
    ct = savefile_read_s32b(file);
    for (i = 0; i < ct; i++)
    {
        char            name[255];
        spell_stats_ptr stats = malloc(sizeof(spell_stats_t));

        memset(stats, 0, sizeof(spell_stats_t));

        savefile_read_cptr(file, name, sizeof(name));
        stats->flags = savefile_read_u32b(file);
        stats->ct_cast = savefile_read_s32b(file);
        stats->ct_fail = savefile_read_s32b(file);
        stats->skill = savefile_read_s32b(file);
        stats->max_skill = savefile_read_s32b(file);
        stats->last_turn = savefile_read_s32b(file);

        str_map_add(map, name, stats);
    }
}
Ejemplo n.º 3
0
void skills_innate_init(cptr name, int current, int max)
{
    _skill_info_ptr info = _innate_info(name);
    if (!info)
    {
        info = malloc(sizeof(_skill_info_t));
        str_map_add(_innate_map(), name, info);
    }
    info->current = current;
    info->max = max;
}
Ejemplo n.º 4
0
spell_stats_ptr spell_stats_aux(cptr name)
{
    str_map_ptr     map = _spell_stats_map();
    spell_stats_ptr result = str_map_find(map, name);

    if (!result)
    {
        result = malloc(sizeof(spell_stats_t));
        memset(result, 0, sizeof(spell_stats_t));
        str_map_add(map, name, result);
    }
    return result;
}
Ejemplo n.º 5
0
void skills_on_load(savefile_ptr file)
{
    str_map_ptr map = _innate_map();
    int         ct, i;

    str_map_clear(map);
    ct = savefile_read_s32b(file);

    for (i = 0; i < ct; i++)
    {
        char            name[255];
        _skill_info_ptr info = malloc(sizeof(_skill_info_t));

        savefile_read_cptr(file, name, sizeof(name));
        info->current = savefile_read_s32b(file);
        info->max = savefile_read_s32b(file);

        str_map_add(map, name, info);
    }

    /* TODO: Spell Skills for Bookless Casters */
    ct = savefile_read_s32b(file);
}
Ejemplo n.º 6
0
void attrs_map_add(attrs_map *map, char *name, char *value) {
  str_map_add(map, name, value);
}
Ejemplo n.º 7
0
/* doc_style_f <-> void * is forbidden in ISO C ... I'm not sure
   what the correct idiom is for a table of function pointers? */
static void _add_doc_style_f(doc_ptr doc, cptr name, doc_style_f f)
{
    doc_style_f *pf = malloc(sizeof(doc_style_f));
    *pf = f;
    str_map_add(doc->styles, name, pf);
}