Example #1
0
  /**
   * Calculates PHYSICAL CRITICAL chance
   *
   * @param attacker
   * @param attacked
   * @float criticalProb
   * @return double
   */
  public static double calculatePhysicalCriticalRate(
      Creature attacker, Creature attacked, float criticalProb) {
    int critical;

    // check always critical
    if (attacker.getObserveController().checkAttackerStatus(AttackStatus.CRITICAL)) return 100;

    if (attacker instanceof Player
        && ((Player) attacker).getEquipment().getSubHandWeaponType() != null)
      critical =
          Math.round(
              (attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_CRITICAL)
                      + attacker.getGameStats().getCurrentStat(StatEnum.SUB_HAND_CRITICAL))
                  / 2);
    else critical = attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_CRITICAL);

    critical =
        Math.round(
            critical * criticalProb
                - attacked.getGameStats().getCurrentStat(StatEnum.PHYSICAL_CRITICAL_RESIST));

    double criticalRate;

    if (critical <= 440) criticalRate = critical * 0.1f;
    else if (critical <= 600) criticalRate = (440 * 0.1f) + ((critical - 440) * 0.05f);
    else criticalRate = (440 * 0.1f) + (160 * 0.05f) + ((critical - 600) * 0.02f);
    // minimal critical rate
    if (criticalRate < 1) criticalRate = 1;

    return criticalRate;
  }
Example #2
0
  /**
   * Calculates DODGE chance
   *
   * @param attacker
   * @param attacked
   * @param accMod
   * @return int
   */
  public static int calculatePhysicalDodgeRate(Creature attacker, Creature attacked, int accMod) {
    // check attack status = BLIND
    if (attacker.getObserveController().checkAttackerStatus(AttackStatus.DODGE)) return 100;
    if (attacker.getEffectController().isAbnormalSet(EffectId.BLIND)) return 100;
    if (attacker.getEffectController().isAbnormalSet(EffectId.BLIND)) return 100;
    int accurancy;

    if (attacker instanceof Player
        && ((Player) attacker).getEquipment().getSubHandWeaponType() != null)
      accurancy =
          Math.round(
              (attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_ACCURACY)
                      + attacker.getGameStats().getCurrentStat(StatEnum.SUB_HAND_ACCURACY))
                  / 2);
    else accurancy = attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_ACCURACY);

    // add bonus stat from effecttemplate
    accurancy += accMod;

    int dodgeRate = (attacked.getGameStats().getCurrentStat(StatEnum.EVASION) - accurancy) / 10;

    // maximal dodge rate
    if (dodgeRate > 30) dodgeRate = 30;

    if (dodgeRate <= 0) return 1;

    return dodgeRate;
  }
Example #3
0
 @Override
 public void onPeriodicAction(Effect effect) {
   Creature effected = effect.getEffected();
   Creature effector = effect.getEffector();
   int valueWithDelta = value + delta * effect.getSkillLevel();
   int damage =
       AttackUtil.calculateMagicalOverTimeSkillResult(
           effect, valueWithDelta, element, this.position);
   effected
       .getController()
       .onAttack(effector, effect.getSkillId(), TYPE.DAMAGE, damage, false, LOG.POISON);
   effected.getObserveController().notifyDotAttackedObservers(effector, effect);
 }
Example #4
0
  /**
   * Calculates BLOCK chance
   *
   * @param attacker
   * @param attacked
   * @return int
   */
  public static int calculatePhysicalBlockRate(Creature attacker, Creature attacked) {
    // check always block
    if (attacked.getObserveController().checkAttackStatus(AttackStatus.BLOCK)) return 100;

    int accuracy;

    if (attacker instanceof Player
        && ((Player) attacker).getEquipment().getSubHandWeaponType() != null)
      accuracy =
          Math.round(
              (attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_ACCURACY)
                      + attacker.getGameStats().getCurrentStat(StatEnum.SUB_HAND_ACCURACY))
                  / 2);
    else accuracy = attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_ACCURACY);

    int blockRate = (attacked.getGameStats().getCurrentStat(StatEnum.BLOCK) - accuracy) / 10;
    // maximal block rate
    if (blockRate > 50) blockRate = 50;

    if (blockRate <= 0) return 1;

    return blockRate;
  }
Example #5
0
  /**
   * Calculates PARRY chance
   *
   * @param attacker
   * @param attacked
   * @return int
   */
  public static int calculatePhysicalParryRate(Creature attacker, Creature attacked) {
    // check always parry
    if (attacked.getObserveController().checkAttackStatus(AttackStatus.PARRY)) return 100;

    int accuracy;

    if (attacker instanceof Player
        && ((Player) attacker).getEquipment().getSubHandWeaponType() != null)
      accuracy =
          Math.round(
              (attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_ACCURACY)
                      + attacker.getGameStats().getCurrentStat(StatEnum.SUB_HAND_ACCURACY))
                  / 2);
    else accuracy = attacker.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_ACCURACY);

    int parryRate = (attacked.getGameStats().getCurrentStat(StatEnum.PARRY) - accuracy) / 10;
    // maximal parry rate
    if (parryRate > 40) parryRate = 40;

    if (parryRate <= 0) return 1;

    return parryRate;
  }
Example #6
0
  /**
   * Calculates RESIST chance
   *
   * @param attacker
   * @param attacked
   * @param accMod
   * @return int
   */
  public static int calculateMagicalResistRate(Creature attacker, Creature attacked, int accMod) {
    if (attacked.getObserveController().checkAttackStatus(AttackStatus.RESIST)) return 100;
    // if(attacker.getEffectController().isAbnormalSet(EffectId.BLIND))
    //  return 100;

    int stat_res = attacked.getGameStats().getCurrentStat(StatEnum.MAGICAL_RESIST);
    int stat_acc = attacker.getGameStats().getCurrentStat(StatEnum.MAGICAL_ACCURACY);

    int attackerLevel = attacker.getLevel();
    int targetLevel = attacked.getLevel();

    // add bonus stat from effecttemplate
    stat_acc += accMod;

    int resist = (stat_res - stat_acc) / 10;

    if ((targetLevel - attackerLevel) > 2) resist += (targetLevel - attackerLevel - 2) * 10;

    if (resist <= 0) // cant resist
    return 0;
    else if (resist > 95) // hardcap 95%
    return 95;
    else return resist;
  }