/
area/city/
area/crypts/
area/guilds/
area/psuedowild/
area/religion/
data/documents/MPDocs/
data/html/
data/mobprogs/
data/quest/
data/world/
data/world/_utilities/
data/world/images/
design/html/
notes/
player/
#if defined(macintosh)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "interp.h"
#include "balance.h"

/*
 * fix_weapon_damage()
 *
 * In order to balance the game, all weapons must do about
 * the same damage based on the object's level.
 *
 * TODO: Add fix for special weapons so they wont be
 * affected, and thus have what is set
 *
 * Weapons do at level 105, 8d18 damage, avg 76
 */
void fix_weapon_damage(OBJ_DATA * obj)
{
    return;
    obj->value[1] = interpolate(obj->level, 1, 8);
    obj->value[2] = interpolate(obj->level, 5, 18);
}


/*
 * fix_spell_damage()
 *
 * Spell damage should be normalized, regardless
 * of whats going on.
 *
 * Avg spell damage should be around 150 total
 */
int fix_spell_damage(int spell_level, int spell_hits)
{
    ++spell_level;
    ++spell_hits;

    int total = number_range(spell_level * 2, spell_level * 4);
    
    total /= spell_hits;
    
    total += 1;
    
    total += number_range(1, 2);
    
    return total;
}

int calculate_spellcost(int level, int mana_cost)
{
    int total;
    
    if (level == 1)
        return mana_cost;
    
    total = (++mana_cost / ++level);
    
    if (total <= 0)
        total = 1;
    
    return total;
}


/*
 * test_spell()
 *
 * Utility to test damage of spells given
 * arguments of level and hits total
 */
void test_spell (CHAR_DATA * ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char buf[MSL];
    int level;
    int hits;
    int dam;
    

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);
    
    if (arg1 == '\0' || arg2 == '\0')
    {
        stc("Syntax: testspell <level> <hits\n", ch);
        return;
    }
    
    level = atoi(arg1);
    hits  = atoi(arg2);
    dam = fix_spell_damage(level, hits);
    
    sprintf(buf, "Spell level:      {R%d{x\n", level);
    stc(buf, ch);
    sprintf(buf, "Spell Hits:       {Y%d{x\n", hits);
    stc(buf, ch);
    sprintf(buf, "Damage per hit:   {W%d{x\n", dam);
    stc(buf, ch);
             stc("---------------------------\n", ch);
    sprintf(buf, "Avg damage:       {w%d{x\n", (dam * hits));
    stc(buf, ch);
}
    
    
/*
 * find_base_attack
 * Determines base attack bonus
 */
int find_base_attack(CHAR_DATA * ch)
{
    int bonus;
    
    switch(ch->class)
    {   default:
            log_string("find base attack: ERROR no class?");
            break;
        case CLASS_FIGHTER:
            bonus = interpolate(ch->level, 1, 20);
            break;
        case CLASS_THIEF:
            bonus = interpolate(ch->level, 1, 15);
            break;
        case CLASS_WIZARD:
            bonus = interpolate(ch->level, 1, 5);
            break;
        case CLASS_PRIEST:
            bonus = interpolate(ch->level, 1, 10);
            break;
        case CLASS_SWORDANGEL:
            bonus = interpolate(ch->level, 1, 30);
            break;
    }
    return bonus;
}

/*
 * level_char_hp()
 *
 * Determines how much hp the player gains on level
 */
int level_char_hp(CHAR_DATA * ch)
{
    int hp;
    
    switch(ch->class)
    {   default:
            log_string("level_char_hp: ERROR no class?");
            break;
        case CLASS_FIGHTER:
            hp = number_range(15, 25);
            break;
        case CLASS_THIEF:
            hp = number_range(11, 19);
            break;
        case CLASS_WIZARD:
            hp = number_range(7, 13);
            break;
        case CLASS_PRIEST:
            hp = number_range(10, 14);
            break;
    }
    return hp;
}

/*
 * level_char_mana()
 *
 * Determines how much mana the player gains per level
 */
int level_char_mana(CHAR_DATA * ch)
{
    int mana;
    
    switch(ch->class)
    {   default:
            log_string("level_char_mana: ERROR no class?");
            break;
        case CLASS_FIGHTER:
            mana = number_range(7, 13);
            break;
        case CLASS_THIEF:
            mana = number_range(10, 14);
            break;
        case CLASS_WIZARD:
            mana = number_range(15, 25);
            break;
        case CLASS_PRIEST:
            mana = number_range(11, 19);
            break;
    }
    return mana;
}

/*
 * level_char_move()
 *
 * Determines how much move per level the player gains
 */
int level_char_move(CHAR_DATA * ch)
{
    int move;
    
    switch(ch->class)
    {   default:
            log_string("level_char_mana: ERROR no class?");
            break;
        case CLASS_FIGHTER:
        case CLASS_THIEF:
        case CLASS_SWORDANGEL:
            move = number_range(10, 20);
            break;
        case CLASS_WIZARD:
        case CLASS_PRIEST:
            move = number_range(7, 13);
            break;
    }
    return move;
}