Exemplo n.º 1
0
result_e spell_base_t::calculate_result( action_state_t* s ) const
{
  result_e result = RESULT_NONE;

  if ( ! s -> target ) return RESULT_NONE;

  if ( ! may_hit ) return RESULT_NONE;

  if ( ( result == RESULT_NONE ) && may_miss )
  {
    if ( rng().roll( miss_chance( composite_hit(), s -> target ) ) )
    {
      result = RESULT_MISS;
    }
  }

  if ( result == RESULT_NONE )
  {
    result = RESULT_HIT;

    if ( may_crit )
    {
      if ( rng().roll( std::max( s -> composite_crit(), 0.0 ) ) )
        result = RESULT_CRIT;
    }
  }

  if ( sim -> debug )
    sim -> out_debug.printf( "%s result for %s is %s", player -> name(), name(), util::result_type_string( result ) );

  return result;
}
Exemplo n.º 2
0
void spell_t::calculate_result()
{
  int delta_level = target -> level - player -> level;

  direct_dmg = 0;
  result = RESULT_NONE;

  if ( ! harmful || ! may_hit ) return;

  if ( ( result == RESULT_NONE ) && may_miss )
  {
    if ( rng[ RESULT_MISS ] -> roll( miss_chance( delta_level ) ) )
    {
      result = RESULT_MISS;
    }
  }

  if ( ( result == RESULT_NONE ) && may_resist && binary )
  {
    if ( rng[ RESULT_RESIST ] -> roll( resistance() ) )
    {
      result = RESULT_RESIST;
    }
  }

  if ( result == RESULT_NONE )
  {
    result = RESULT_HIT;

    if ( may_crit )
    {
      if ( rng[ RESULT_CRIT ] -> roll( crit_chance( delta_level ) ) )
      {
        result = RESULT_CRIT;
      }
    }
  }

  if ( sim -> debug ) log_t::output( sim, "%s result for %s is %s", player -> name(), name(), util_t::result_type_string( result ) );
}