예제 #1
0
void Character::update_health(int external_modifiers)
{
    // Limit healthy_mod to [-200, 200].
    // This also sets approximate bounds for the character's health.
    if( get_healthy_mod() > 200 ) {
        set_healthy_mod( 200 );
    } else if( get_healthy_mod() < -200 ) {
        set_healthy_mod( -200 );
    }

    // Over the long run, health tends toward healthy_mod.
    int break_even = get_healthy() - get_healthy_mod() + external_modifiers;

    // But we allow some random variation.
    const long roll = rng( -100, 100 );
    if( roll > break_even ) {
        mod_healthy( 1 );
    } else if( roll < break_even ) {
        mod_healthy( -1 );
    }

    // And healthy_mod decays over time.
    set_healthy_mod( get_healthy_mod() * 3 / 4 );

    add_msg( m_debug, "Health: %d, Health mod: %d", get_healthy(), get_healthy_mod() );
}
예제 #2
0
void Character::mod_stat( const std::string &stat, int modifier )
{
    if( stat == "str" ) {
        mod_str_bonus( modifier );
    } else if( stat == "dex" ) {
        mod_dex_bonus( modifier );
    } else if( stat == "per" ) {
        mod_per_bonus( modifier );
    } else if( stat == "int" ) {
        mod_int_bonus( modifier );
    } else if( stat == "healthy" ) {
        mod_healthy( modifier );
    } else if( stat == "hunger" ) {
        mod_hunger( modifier );
    } else if( stat == "speed" ) {
        mod_speed_bonus( modifier );
    } else if( stat == "dodge" ) {
        mod_dodge_bonus( modifier );
    } else if( stat == "block" ) {
        mod_block_bonus( modifier );
    } else if( stat == "hit" ) {
        mod_hit_bonus( modifier );
    } else if( stat == "bash" ) {
        mod_bash_bonus( modifier );
    } else if( stat == "cut" ) {
        mod_cut_bonus( modifier );
    } else if( stat == "pain" ) {
        mod_pain( modifier );
    } else if( stat == "moves" ) {
        mod_moves( modifier );
    } else {
        Creature::mod_stat( stat, modifier );
    }
}
예제 #3
0
void Creature::mod_stat( std::string stat, int modifier )
{
    if( stat == "str" ) {
        mod_str_bonus( modifier );
    } else if( stat == "dex" ) {
        mod_dex_bonus( modifier );
    } else if( stat == "per" ) {
        mod_per_bonus( modifier );
    } else if( stat == "int" ) {
        mod_int_bonus( modifier );
    } else if( stat == "healthy" ) {
        mod_healthy( modifier );
    } else if( stat == "healthy_mod" ) {
        mod_healthy_mod( modifier );
    } else if( stat == "speed" ) {
        mod_speed_bonus( modifier );
    } else if( stat == "dodge" ) {
        mod_dodge_bonus( modifier );
    } else if( stat == "block" ) {
        mod_block_bonus( modifier );
    } else if( stat == "hit" ) {
        mod_hit_bonus( modifier );
    } else if( stat == "bash" ) {
        mod_bash_bonus( modifier );
    } else if( stat == "cut" ) {
        mod_cut_bonus( modifier );
    } else if( stat == "pain" ) {
        mod_pain( modifier );
    } else if( stat == "moves" ) {
        mod_moves( modifier );
    } else {
        add_msg( "Tried to modify a nonexistent stat %s.", stat.c_str() );
    }
}
예제 #4
0
void Creature::update_health(int base_threshold)
{
    if (get_healthy_mod() > 200) {
        set_healthy_mod(200);
    } else if (get_healthy_mod() < -200) {
        set_healthy_mod(-200);
    }
    int roll = rng(-100, 100);
    base_threshold += get_healthy() - get_healthy_mod();
    if (roll > base_threshold) {
        mod_healthy(1);
    } else if (roll < base_threshold) {
        mod_healthy(-1);
    }
    set_healthy_mod(get_healthy_mod() * 3 / 4);

    add_msg( m_debug, "Health: %d, Health mod: %d", get_healthy(), get_healthy_mod());
}