bool restore_mana(void)
{
    bool   result = FALSE;
    slot_t slot;

    if (p_ptr->pclass == CLASS_MAGIC_EATER)
    {
        magic_eater_restore();
        result = TRUE;
    }
    else if (p_ptr->csp < p_ptr->msp)
    {
        if (p_ptr->pclass == CLASS_RUNE_KNIGHT)
            p_ptr->csp += (p_ptr->msp - p_ptr->csp) / 3;
        else
            p_ptr->csp = p_ptr->msp;

        p_ptr->csp_frac = 0;
        p_ptr->redraw |= (PR_MANA);
        p_ptr->window |= (PW_SPELL);
        result = TRUE;
    }

    for (slot = 1; slot <= pack_max(); slot++)
    {
        obj_ptr obj = pack_obj(slot);

        if (!obj) continue;
        if (!object_is_device(obj)) continue;
        if (obj->activation.type == EFFECT_RESTORE_MANA) continue;

        if (obj->tval == TV_ROD)
            device_regen_sp_aux(obj, 500);
        else
            device_regen_sp_aux(obj, 250);
        result = TRUE;
    }

    msg_print("You feel your head clear.");
    return result;
}
Exemple #2
0
bool restore_mana(void)
{
    bool result = FALSE;
    int  i;

    if (p_ptr->pclass == CLASS_MAGIC_EATER)
    {
        magic_eater_restore();
        result = TRUE;
    }
    else if (p_ptr->csp < p_ptr->msp)
    {
        if (p_ptr->pclass == CLASS_RUNE_KNIGHT)
            p_ptr->csp += (p_ptr->msp - p_ptr->csp) / 3;
        else
            p_ptr->csp = p_ptr->msp;

        p_ptr->csp_frac = 0;
        p_ptr->redraw |= (PR_MANA);
        p_ptr->window |= (PW_SPELL);
        result = TRUE;
    }

    for (i = 0; i < INVEN_PACK; i++)
    {
        if (!inventory[i].k_idx) continue;
        if (!object_is_device(&inventory[i])) continue;
        if (inventory[i].activation.type == EFFECT_RESTORE_MANA) continue;

        if (inventory[i].tval == TV_ROD)
            device_regen_sp_aux(&inventory[i], 500);
        else
            device_regen_sp_aux(&inventory[i], 250);
    }

    msg_print("You feel your head clear.");
    return result;
}