Esempio n. 1
0
  @Override
  public void onDie(Creature lastAttacker) {
    super.onDie(lastAttacker);

    Npc owner = getOwner();

    addTask(TaskId.DECAY, RespawnService.scheduleDecayTask(this.getOwner()));
    scheduleRespawn();

    PacketSendUtility.broadcastPacket(
        owner,
        new SM_EMOTION(
            owner, EmotionType.DIE, 0, lastAttacker == null ? 0 : lastAttacker.getObjectId()));

    // Monster Controller overrides this method.
    this.doReward();
    Npc npc = getOwner();
    List<QuestDrop> drops = QuestEngine.getInstance().getQuestDrop(npc.getNpcId());
    if (drops.size() > 0) {
      DropService.getInstance()
          .registerDrop(getOwner(), (Player) lastAttacker, lastAttacker.getLevel());
    }
    owner.getAi().handleEvent(Event.DIED);

    // deselect target at the end
    owner.setTarget(null);
    PacketSendUtility.broadcastPacket(owner, new SM_LOOKATOBJECT(owner));
  }
Esempio n. 2
0
  /**
   * @param player
   * @param target
   * @return
   */
  public static long calculateGroupExperienceReward(int maxLevelInRange, Creature target) {
    int targetLevel = target.getLevel();

    int baseXP = ((Npc) target).getObjectTemplate().getStatsTemplate().getMaxXp();
    int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - maxLevelInRange);

    return (int) Math.floor(baseXP * xpPercentage / 100);
  }
Esempio n. 3
0
  /**
   * @param player
   * @param target
   * @return XP reward from target
   */
  public static long calculateSoloExperienceReward(Player player, Creature target) {
    int playerLevel = player.getCommonData().getLevel();
    int targetLevel = target.getLevel();

    int baseXP = ((Npc) target).getObjectTemplate().getStatsTemplate().getMaxXp();
    int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);

    return (int) Math.floor(baseXP * xpPercentage * player.getRates().getXpRate() / 100);
  }
Esempio n. 4
0
  /**
   * @param maxLevelInRange
   * @param target
   * @return
   */
  public static int calculateGroupAPReward(int maxLevelInRange, Creature target) {
    int targetLevel = target.getLevel();
    NpcRank npcRank = ((Npc) target).getObjectTemplate().getRank();

    // TODO: fix to see monster Rank level, NORMAL lvl 1, 2 | ELITE lvl 1, 2 etc..
    int baseAP = 10 + calculateRankMultipler(npcRank) - 1;

    int apPercentage = XPRewardEnum.xpRewardFrom(targetLevel - maxLevelInRange);

    return (int) Math.floor(baseAP * apPercentage / 100);
  }
Esempio n. 5
0
  /**
   * @param player
   * @param target
   * @return DP reward
   */
  public static int calculateGroupDPReward(Player player, Creature target) {
    int playerLevel = player.getCommonData().getLevel();
    int targetLevel = target.getLevel();
    NpcRank npcRank = ((Npc) target).getObjectTemplate().getRank();

    // TODO: fix to see monster Rank level, NORMAL lvl 1, 2 | ELITE lvl 1, 2 etc..
    int baseDP = targetLevel * calculateRankMultipler(npcRank);

    int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);

    return (int) Math.floor(baseDP * xpPercentage * player.getRates().getGroupXpRate() / 100);
  }
Esempio n. 6
0
  /**
   * ref:
   * http://www.aionsource.com/forum/mechanic-analysis/42597-character-stats-xp-dp-origin-gerbator-team-july-2009-a.html
   *
   * @param player
   * @param target
   * @return DP reward from target
   */
  public static int calculateSoloDPReward(Player player, Creature target) {
    int playerLevel = player.getCommonData().getLevel();
    int targetLevel = target.getLevel();
    NpcRank npcRank = ((Npc) target).getObjectTemplate().getRank();

    // TODO: fix to see monster Rank level, NORMAL lvl 1, 2 | ELITE lvl 1, 2 etc..
    // look at:
    // http://www.aionsource.com/forum/mechanic-analysis/42597-character-stats-xp-dp-origin-gerbator-team-july-2009-a.html
    int baseDP = targetLevel * calculateRankMultipler(npcRank);

    int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);
    return (int) Math.floor(baseDP * xpPercentage * player.getRates().getXpRate() / 100);
  }
Esempio n. 7
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;
  }
  /** {@inheritDoc} */
  @Override
  protected void writeImpl(AionConnection con, ByteBuffer buf) {
    writeF(buf, npc.getX()); // x
    writeF(buf, npc.getY()); // y
    writeF(buf, npc.getZ()); // z
    writeD(buf, npc.getObjectId());
    writeD(buf, npcId);
    writeD(buf, npcId);

    writeC(buf, npcTypeId);

    writeH(
        buf,
        npc
            .getState()); // unk 65=normal,0x47 (71)= [dead npc ?]no drop,0x21(33)=fight
                          // state,0x07=[dead monster?]
    // no drop
    // 3,19 - wings spread (NPCs)
    // 5,6,11,21 - sitting (NPC)
    // 7,23 - dead (no drop)
    // 8,24 - [dead][NPC only] - looks like some orb of light (no normal mesh)
    // 32,33 - fight mode

    writeC(buf, npc.getHeading());
    writeD(buf, npcTemplate.getNameId());
    writeD(buf, npcTemplate.getTitleId()); // titleID

    writeH(buf, 0x00); // unk
    writeC(buf, 0x00); // unk
    writeD(buf, 0x00); // unk

    /*
     * Master Info (Summon, Kisk, Etc)
     */
    writeD(buf, masterObjId); // masterObjectId
    writeS(buf, masterName); // masterName

    int maxHp = npc.getLifeStats().getMaxHp();
    int currHp = npc.getLifeStats().getCurrentHp();
    writeC(buf, 100 * currHp / maxHp); // %hp
    writeD(buf, npc.getGameStats().getCurrentStat(StatEnum.MAXHP));
    writeC(buf, npc.getLevel()); // lvl

    NpcEquippedGear gear = npcTemplate.getEquipment();
    if (gear == null) writeH(buf, 0x00);
    else {
      writeH(buf, gear.getItemsMask());
      for (Entry<ItemSlot, ItemTemplate> item :
          gear) // getting it from template ( later if we make sure that npcs actually use items,
                // we'll make Item from it )
      {
        writeD(buf, item.getValue().getTemplateId());
        writeD(buf, 0x00);
        writeD(buf, 0x00);
        writeH(buf, 0x00);
      }
    }

    writeF(buf, 1.5f); // unk
    writeF(buf, npcTemplate.getHeight());
    writeF(buf, npc.getMoveController().getSpeed()); // speed

    writeH(buf, 2000); // 0x834 (depends on speed ? )
    writeH(buf, 2000); // 0x834

    if (npc instanceof Servant) writeC(buf, 0x01); // unk
    else writeC(buf, 0x00);

    /** Movement */
    writeF(buf, npc.getX()); // x
    writeF(buf, npc.getY()); // y
    writeF(buf, npc.getZ()); // z
    writeC(buf, 0x00); // move type

    SpawnTemplate spawn = npc.getSpawn();
    if (spawn == null) {
      writeH(buf, 0);
    } else {
      int mask =
          (Math.round(spawn.getStaticid() / 0xFF) < 0 ? 0 : Math.round(spawn.getStaticid() / 0xFF));
      byte[] statics = new byte[] {(byte) spawn.getStaticid(), (byte) mask};
      writeB(buf, statics);
    }

    writeC(buf, 0);
    writeC(buf, 0); // all unknown
    writeC(buf, 0);
    writeC(buf, 0);
    writeC(buf, 0);
    writeC(buf, 0);
    writeC(buf, 0);
    writeC(buf, 0);
    writeC(buf, npc.getVisualState()); // visualState

    /** 1 : normal (kisk too) 2 : summon 32 : trap 1024 : holy servant, noble energy */
    writeH(buf, npc.getNpcObjectType().getId());
    writeC(buf, 0x00); // unk
    if (npc instanceof Artifact) {
      writeD(buf, 0);
    } else {
      writeD(buf, npc.getTarget() == null ? 0 : npc.getTarget().getObjectId());
    }
  }
Esempio n. 9
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;
  }
Esempio n. 10
0
 /**
  * @param player
  * @param target
  * @return AP reward
  */
 public static int calculateSoloAPReward(Player player, Creature target) {
   int playerLevel = player.getCommonData().getLevel();
   int targetLevel = target.getLevel();
   int percentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);
   return (int) Math.floor(10 * percentage * player.getRates().getApNpcRate() / 100);
 }