Package net.sf.l2j.gameserver.templates

Examples of net.sf.l2j.gameserver.templates.L2Weapon


        activeSummon.getOwner().sendPacket(sm);
      }
     
      if (!miss && (damage > 0))
      {
        L2Weapon weapon = getActiveWeaponItem();
        boolean isBow = ((weapon != null) && weapon.getItemType().toString().equalsIgnoreCase("Bow"));
       
        if (!isBow) // Do not reflect or absorb if weapon is of type bow
        {
          // Reduce HP of the target and calculate reflection damage to reduce HP of attacker if necessary
          double reflectPercent = target.getStat().calcStat(Stats.REFLECT_DAMAGE_PERCENT, 0, null, null);
         
          if (reflectPercent > 0)
          {
            int reflectedDamage = (int) ((reflectPercent / 100.) * damage);
            damage -= reflectedDamage;
           
            if (reflectedDamage > target.getMaxHp())
            {
              reflectedDamage = target.getMaxHp();
            }
           
            getStatus().reduceHp(reflectedDamage, target, true);
           
            // Custom messages - nice but also more network load
            /*
             * if (target instanceof L2PcInstance) ((L2PcInstance)target).sendMessage("You reflected " + reflectedDamage + " damage."); else if (target instanceof L2Summon) ((L2Summon)target).getOwner().sendMessage("Summon reflected " + reflectedDamage + " damage."); if (this instanceof
             * L2PcInstance) ((L2PcInstance)this).sendMessage("Target reflected to you " + reflectedDamage + " damage."); else if (this instanceof L2Summon) ((L2Summon)this).getOwner().sendMessage("Target reflected to your summon " + reflectedDamage + " damage.");
             */
          }
         
          // Absorb HP from the damage inflicted
          double absorbPercent = getStat().calcStat(Stats.ABSORB_DAMAGE_PERCENT, 0, null, null);
         
          if (absorbPercent > 0)
          {
            int maxCanAbsorb = (int) (getMaxHp() - getCurrentHp());
            int absorbDamage = (int) ((absorbPercent / 100.) * damage);
           
            if (absorbDamage > maxCanAbsorb)
            {
              absorbDamage = maxCanAbsorb; // Can't absord more than max hp
            }
           
            if (absorbDamage > 0)
            {
              setCurrentHp(getCurrentHp() + absorbDamage);
             
              // Custom messages - nice but also more network load
              /*
               * if (this instanceof L2PcInstance) ((L2PcInstance)this).sendMessage("You absorbed " + absorbDamage + " damage."); else if (this instanceof L2Summon) ((L2Summon)this).getOwner().sendMessage("Summon absorbed " + absorbDamage + " damage."); else if (Config.DEBUG)
               * _log.info(getName() + " absorbed " + absorbDamage + " damage.");
               */
            }
          }
        }
       
        target.reduceCurrentHp(damage, this);
       
        // Notify AI with EVT_ATTACKED
        target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, this);
        getAI().clientStartAutoAttack();
       
        // Manage attack or cast break of the target (calculating rate, sending message...)
        if (!target.isRaid() && Formulas.getInstance().calcAtkBreak(target, damage))
        {
          target.breakAttack();
          target.breakCast();
        }
      }
     
      // Launch weapon Special ability effect if available
      L2Weapon activeWeapon = getActiveWeaponItem();
     
      if (activeWeapon != null)
      {
        activeWeapon.getSkillEffects(this, target, crit);
      }
     
      /*
       * COMMENTED OUT BY nexus - 2006-08-17 We must not discharge the soulshouts at the onHitTimer method, as this can cause unwanted soulshout consumption if the attacker recharges the soulshot right after an attack request but before his hit actually lands on the target. The soulshot
       * discharging has been moved to the doAttack method: As soon as we know that we didn't missed the hit there, then we must discharge any charged soulshots.
View Full Code Here


        if (target instanceof L2Character)
        {
          // Set some values inside target's instance for later use
          L2Character player = (L2Character) target;
         
          L2Weapon activeWeapon = getActiveWeaponItem();
          // Launch weapon Special ability skill effect if available
          if ((activeWeapon != null) && !((L2Character) target).isDead())
          {
            if ((activeWeapon.getSkillEffects(this, player, skill).length > 0) && (this instanceof L2PcInstance))
            {
              sendPacket(SystemMessage.sendString("Target affected by weapon special ability!"));
            }
          }
         
View Full Code Here

   * @param target the target
   * @return the random damage
   */
  public final int getRandomDamage(L2Character target)
  {
    L2Weapon weaponItem = getActiveWeaponItem();
   
    if (weaponItem == null)
    {
      return 5 + (int) Math.sqrt(getLevel());
    }
   
    return weaponItem.getRandomDamage();
  }
View Full Code Here

        player.sendPacket(new SystemMessage(SystemMessageId.CAN_USE_REELING_ONLY_WHILE_FISHING));
      }
      player.sendPacket(new ActionFailed());
      return;
    }
    L2Weapon weaponItem = player.getActiveWeaponItem();
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    if(weaponInst == null || weaponItem == null)
      return;
    int SS = 1;
    int pen = 0;
    if (weaponInst.getChargedFishshot()) SS = 2;
    double gradebonus = 1 + weaponItem.getCrystalType() * 0.1;
    int dmg = (int)(skill.getPower()*gradebonus*SS);
    if (player.getSkillLevel(1315) <= skill.getLevel()-2) //1315 - Fish Expertise
    {//Penalty
      player.sendPacket(new SystemMessage(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY));
            pen = 50;
View Full Code Here

    if (player.isInCraftMode() || player.isInStoreMode()) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_FISH_WHILE_USING_RECIPE_BOOK));
      if (!player.isGM())
        return;
    }
    L2Weapon weaponItem = player.getActiveWeaponItem();
    if ((weaponItem==null || weaponItem.getItemType() != L2WeaponType.ROD))
    {
      //Fishing poles are not installed
      player.sendPacket(new SystemMessage(SystemMessageId.FISHING_POLE_NOT_EQUIPPED));
      return;
    }
View Full Code Here

    }
    // In C5 summons make 10 % less dmg in PvP.
    if(attacker instanceof L2Summon && target instanceof L2PcInstance) damage *= 0.9;

    // defence modifier depending of the attacker weapon
    L2Weapon weapon = attacker.getActiveWeaponItem();
    Stats stat = null;
    if (weapon != null)
    {
      switch (weapon.getItemType())
      {
        case BOW:
          stat = Stats.BOW_WPN_VULN;
          break;
        case BLUNT:
View Full Code Here

        double init = 0;

    if (Config.ALT_GAME_CANCEL_CAST && target.isCastingNow()) init = 50;
    if (Config.ALT_GAME_CANCEL_BOW && target.isAttackingNow())
    {
      L2Weapon wpn = target.getActiveWeaponItem();
      if (wpn != null && wpn.getItemType() == L2WeaponType.BOW) init = 15;
    }

        if (init <= 0) return false; // No attack break

        // Chance of break is higher with higher dmg
View Full Code Here

   * @param target
   * @return
   */
  public boolean calcShldUse(L2Character attacker, L2Character target)
  {
    L2Weapon at_weapon = attacker.getActiveWeaponItem();
    double shldRate = target.calcStat(Stats.SHIELD_RATE, 0, attacker, null)
      * DEXbonus[target.getDEX()];
    if (shldRate == 0.0) return false;
    // Check for passive skill Aegis (316) or Aegis Stance (318)
    if (target.getKnownSkill(316) == null && target.getFirstEffect(318) == null)
      if (!target.isFront(attacker)) return false;
    // if attacker use bow and target wear shield, shield block rate is multiplied by 1.3 (30%)
    if (at_weapon != null && at_weapon.getItemType() == L2WeaponType.BOW)
      shldRate *= 1.3;
    return shldRate > Rnd.get(100);
  }
View Full Code Here

    private void makeItem()
    {
        if (_currentItem.item != null) return;
        if (_currentItem.type instanceof L2ArmorType) _currentItem.item = new L2Armor(
            (L2ArmorType) _currentItem.type, _currentItem.set);
        else if (_currentItem.type instanceof L2WeaponType) _currentItem.item = new L2Weapon(
            (L2WeaponType) _currentItem.type, _currentItem.set);
        else if (_currentItem.type instanceof L2EtcItemType) _currentItem.item = new L2EtcItem(
            (L2EtcItemType) _currentItem.type, _currentItem.set);
        else throw new Error("Unknown item type " + _currentItem.type);
    }
View Full Code Here

  {

    if (env.target == null)
      return false;

    L2Weapon item = env.target.getActiveWeaponItem();

    if(item == null)
      return false;

    return (item.getItemType().mask() & _weaponMask) != 0;
  }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.templates.L2Weapon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.