예제 #1
0
  /**
   * @param attacker
   * @param target
   * @return
   */
  public static int calculateSubHandPhysicDamageToTarget(Creature attacker, Creature attacked) {
    CreatureGameStats<?> ags = attacker.getGameStats();

    int min = ags.getCurrentStat(StatEnum.SUB_MIN_DAMAGES);
    int max = ags.getCurrentStat(StatEnum.SUB_MAX_DAMAGES);
    int average = Math.round((min + max) / 2);

    Equipment equipment = ((Player) attacker).getEquipment();

    if (average < 1) {
      average = 1;
      log.warn("Weapon stat MIN_MAX_DAMAGE resulted average zero in sub-hand calculation");
      log.warn(
          "Weapon ID: "
              + String.valueOf(equipment.getSubHandWeapon().getItemTemplate().getTemplateId()));
      log.warn("MIN_DAMAGE = " + String.valueOf(min));
      log.warn("MAX_DAMAGE = " + String.valueOf(max));
    }

    int base = Rnd.get(min, max);

    int damage = base + ags.getStatBonus(StatEnum.SUB_HAND_PHYSICAL_ATTACK);

    if (attacker.isInState(CreatureState.POWERSHARD)) {
      Item subHandPowerShard = equipment.getSubHandPowerShard();
      if (subHandPowerShard != null) {
        damage += subHandPowerShard.getItemTemplate().getWeaponBoost();
        equipment.usePowerShard(subHandPowerShard, 1);
      }
    }
    int dualEffect = ((Player) attacker).getEffectController().getDualEffect();
    if (dualEffect == 0) {
      log.warn(
          "Missing dualeffect for player "
              + ((Player) attacker).getName()
              + " possible hack? or bug?");
      dualEffect = 25;
    }

    if (Rnd.get(0, 100) < 25) damage *= (dualEffect * 0.007f);

    // physical defense
    damage -= Math.round(attacked.getGameStats().getCurrentStat(StatEnum.PHYSICAL_DEFENSE) * 0.10f);

    if (damage <= 0) damage = 1;

    return damage;
  }
예제 #2
0
  /**
   * @param attacker
   * @param target
   * @param skillDamages
   * @return Damage made to target (-hp value)
   */
  public static int calculateMagicalAttackToTarget(
      Creature attacker, Creature attacked, SkillElement element) {
    CreatureGameStats<?> ags = attacker.getGameStats();

    int resultDamage = 0;

    if (attacker instanceof Player) {
      int min = ags.getCurrentStat(StatEnum.MAIN_MIN_DAMAGES);
      int max = ags.getCurrentStat(StatEnum.MAIN_MAX_DAMAGES);

      Equipment equipment = ((Player) attacker).getEquipment();

      int base = Math.round(Rnd.get(min, max) * ags.getCurrentStat(StatEnum.KNOWLEDGE) * 0.01f);

      resultDamage = base + ags.getStatBonus(StatEnum.MAGICAL_ATTACK);

      if (attacker.isInState(CreatureState.POWERSHARD)) {
        Item mainHandPowerShard = equipment.getMainHandPowerShard();
        if (mainHandPowerShard != null) {
          resultDamage += mainHandPowerShard.getItemTemplate().getWeaponBoost();

          equipment.usePowerShard(mainHandPowerShard, 1);
        }
      }
    }

    // magical resistance
    resultDamage =
        Math.round(
            resultDamage * (1 - attacked.getGameStats().getMagicalDefenseFor(element) / 1000f));

    if (resultDamage <= 0) resultDamage = 1;

    return resultDamage;
  }
예제 #3
0
파일: Reader.java 프로젝트: osiris087/aionj
  private Worker choose() {
    idles.clear();
    nbFull = 0;
    last = 0;
    identics = true;
    elected = null;
    minQueueSize = Integer.MAX_VALUE;

    for (i = 0; i < workers.size(); i++) {
      w = workers.get(i);

      if (!w.isIdle()) {
        if (w.isFull()) {
          nbFull++;
          continue;
        }

        queueSize = w.getQueueSize();

        if (last == 0) {
          last = queueSize;
        } else {
          if (last != queueSize) {
            identics = false;
          }
        }

        if (queueSize < minQueueSize) {
          minQueueSize = queueSize;
          elected = w;
        }
      } else {
        idles.add(w);
      }
    }

    if (idles.size() > 0) {
      elected = idles.get(Rnd.get(idles.size()));
    } else {
      if (nbFull == workers.size() || identics) {
        elected = workers.get(Rnd.get(workers.size()));
      }
    }

    return elected;
  }
예제 #4
0
 private static boolean isDrop(Player player, QuestDrop drop) {
   NpcDropStat stats = player.getNpcDropStats(drop.getNpcId());
   double chance = stats.getItemLootChance(drop.getItemId());
   // if not in collection, set initial value
   if (chance == 0) {
     stats.setItemLootChance(drop.getItemId(), drop.getChance());
     chance = drop.getChance();
   }
   boolean result = true;
   if (Rnd.get() * 100 > chance) result = false;
   stats.updateStat(drop.getItemId(), result);
   return result;
 }
예제 #5
0
 @Override
 public HandlerResult onBonusApplyEvent(QuestCookie env, int index, AbstractInventoryBonus bonus) {
   if (!(bonus instanceof CutSceneBonus)) return HandlerResult.UNKNOWN;
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
     int var1 = qs.getQuestVarById(1);
     int var2 = qs.getQuestVarById(2);
     qs.setQuestVarById(1, var1 + 1);
     // randomize movie
     if ((var1 == 1 && var2 == 0) || var1 == 0 && Rnd.get() * 100 < 50) {
       if (qs.getCompleteCount() == 9)
         ItemService.addItems(player, Collections.singletonList(new QuestItems(188051106, 1)));
       qs.setQuestVarById(2, 1);
       return HandlerResult.SUCCESS;
     }
   }
   return HandlerResult.FAILED;
 }
예제 #6
0
  /** @return */
  private static int getNbRift() {
    double rnd = Rnd.get(0, 99);

    /*
     * 0 : 29%
     * 1 : 45%
     * 2 : 15%
     * 3 : 5%
     * 4 : 3%
     * 5 : 2%
     * 6 : 1%
     */

    if (rnd == 0) return 6;
    else if (rnd <= 2) return 5;
    else if (rnd <= 5) return 4;
    else if (rnd <= 10) return 3;
    else if (rnd <= 25) return 2;
    else if (rnd <= 70) return 1;
    else return 0;
  }
예제 #7
0
  /**
   * @param player
   * @param target
   * @param skillDamages
   * @return Damage made to target (-hp value)
   */
  public static int calculatePhysicDamageToTarget(
      Creature attacker, Creature attacked, int skillDamages, int bonusDamages) {
    CreatureGameStats<?> ags = attacker.getGameStats();

    int resultDamage = 0;

    if (attacker instanceof Player) {
      int min = ags.getCurrentStat(StatEnum.MAIN_MIN_DAMAGES);
      int max = ags.getCurrentStat(StatEnum.MAIN_MAX_DAMAGES);
      int min2 = ags.getCurrentStat(StatEnum.SUB_MIN_DAMAGES);
      int max2 = ags.getCurrentStat(StatEnum.SUB_MAX_DAMAGES);

      // weapon with higher average should be taken into account for skills
      if (skillDamages > 0) {
        if (((min + max) / 2) < ((min2 + max2) / 2)) {
          min = min2;
          max = max2;
        }
      }

      int average = Math.round((min + max) / 2);

      Equipment equipment = ((Player) attacker).getEquipment();

      WeaponType weaponType = equipment.getMainHandWeaponType();

      if (weaponType != null) {
        if (average < 1) {
          average = 1;
          log.warn("Weapon stat MIN_MAX_DAMAGE resulted average zero in main-hand calculation");
          log.warn(
              "Weapon ID: "
                  + String.valueOf(
                      equipment.getMainHandWeapon().getItemTemplate().getTemplateId()));
          log.warn("MIN_DAMAGE = " + String.valueOf(min));
          log.warn("MAX_DAMAGE = " + String.valueOf(max));
        }

        int base = Math.round(Rnd.get(min, max) * ags.getCurrentStat(StatEnum.POWER) * 0.01f);

        resultDamage =
            base
                + ags.getStatBonus(StatEnum.MAIN_HAND_PHYSICAL_ATTACK)
                + skillDamages
                + bonusDamages;

      } else // if hand attack
      {
        int base = Rnd.get(16, 20);
        resultDamage = Math.round(base * (ags.getCurrentStat(StatEnum.POWER) * 0.01f));
      }

      if (attacker.isInState(CreatureState.POWERSHARD)) {
        Item mainHandPowerShard = equipment.getMainHandPowerShard();
        if (mainHandPowerShard != null) {
          resultDamage += mainHandPowerShard.getItemTemplate().getWeaponBoost();

          equipment.usePowerShard(mainHandPowerShard, 1);
        }
      }
    } else if (attacker instanceof Summon) {
      int baseDamage = ags.getCurrentStat(StatEnum.MAIN_HAND_PHYSICAL_ATTACK);
      // 10% range for summon attack
      int max = ((baseDamage * attacker.getLevel()) / 10);
      int min = Math.round(max * 0.9f);
      resultDamage += Rnd.get(min, max);
    } else {
      NpcRank npcRank = ((Npc) attacker).getObjectTemplate().getRank();
      double multipler = calculateRankMultipler(npcRank);
      double hpGaugeMod = 1 + (((Npc) attacker).getObjectTemplate().getHpGauge() / 10);
      int baseDamage = ags.getCurrentStat(StatEnum.MAIN_HAND_PHYSICAL_ATTACK);
      int max =
          (int) ((baseDamage * multipler * hpGaugeMod) + ((baseDamage * attacker.getLevel()) / 10));
      int min = max - ags.getCurrentStat(StatEnum.MAIN_HAND_PHYSICAL_ATTACK);
      resultDamage += Rnd.get(min, max);
    }

    // physical defense
    resultDamage -=
        Math.round(attacked.getGameStats().getCurrentStat(StatEnum.PHYSICAL_DEFENSE) * 0.10f);

    if (resultDamage <= 0) resultDamage = 1;

    return resultDamage;
  }