Package com.l2jfrozen.gameserver.templates

Examples of com.l2jfrozen.gameserver.templates.L2Weapon


        activeChar.sendPacket(new UserInfo(activeChar));
      }
    }
    else
    {
      L2Weapon weaponItem = activeChar.getActiveWeaponItem();
      int itemid = item.getItemId();
      // _log.log(Level.WARNING, "item not equipable id:"+ item.getItemId());
      if (itemid == 4393)
      {
        activeChar.sendPacket(new ShowCalculator(4393));
      }
      else if (weaponItem != null && weaponItem.getItemType() == L2WeaponType.ROD && (itemid >= 6519 && itemid <= 6527 || itemid >= 7610 && itemid <= 7613 || itemid >= 7807 && itemid <= 7809 || itemid >= 8484 && itemid <= 8486 || itemid >= 8505 && itemid <= 8513))
      {
        activeChar.getInventory().setPaperdollItem(Inventory.PAPERDOLL_LHAND, item);
        activeChar.broadcastUserInfo();
        // Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipement
        ItemList il = new ItemList(activeChar, false);
View Full Code Here


    // Get the active weapon instance (always equiped in the right hand)
    L2ItemInstance weaponInst = getActiveWeaponInstance();

    // Get the active weapon item corresponding to the active weapon instance (always equiped in the right hand)
    L2Weapon weaponItem = getActiveWeaponItem();
   
    if(weaponItem != null && weaponItem.getItemType() == L2WeaponType.ROD)
    {
      //  You can't make an attack with a fishing pole.
      ((L2PcInstance) this).sendPacket(new SystemMessage(SystemMessageId.CANNOT_ATTACK_WITH_FISHING_POLE));
      getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);

      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    // TEMPFIX: Check client Z coordinate instead of server z to avoid exploit
    // killing Zaken from others floor
    if ((target instanceof L2GrandBossInstance) && ((L2GrandBossInstance) target).getNpcId() == 29022)
    {
      if (Math.abs(this.getClientZ() - target.getZ()) > 200)
      {
        sendPacket(new SystemMessage(SystemMessageId.CANT_SEE_TARGET));
        getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
    }

    // GeoData Los Check here (or dz > 1000)
    if(!GeoData.getInstance().canSeeTarget(this, target))
    {
      sendPacket(new SystemMessage(SystemMessageId.CANT_SEE_TARGET));
      getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Check for a bow
    if(weaponItem != null && weaponItem.getItemType() == L2WeaponType.BOW)
    {
     
      // Equip arrows needed in left hand and send a Server->Client packet ItemList to the L2PcINstance then return True
      if(!checkAndEquipArrows())
      {
        // Cancel the action because the L2PcInstance have no arrow
        getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);

        sendPacket(ActionFailed.STATIC_PACKET);
        sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ARROWS));
        return;
      }
     
      //Check for arrows and MP
      if(this instanceof L2PcInstance)
      {
        // Checking if target has moved to peace zone - only for player-bow attacks at the moment
        // Other melee is checked in movement code and for offensive spells a check is done every time
        if(target.isInsidePeaceZone((L2PcInstance) this))
        {
          getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
          sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }

        // Verify if the bow can be use
        if(_disableBowAttackEndTime <= GameTimeController.getGameTicks())
        {
          // Verify if L2PcInstance owns enough MP
          int saMpConsume = (int) getStat().calcStat(Stats.MP_CONSUME, 0, null, null);
          int mpConsume = saMpConsume == 0 ? weaponItem.getMpConsume() : saMpConsume;

          if(getCurrentMp() < mpConsume)
          {
            // If L2PcInstance doesn't have enough MP, stop the attack
            ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(CtrlEvent.EVT_READY_TO_ACT), 1000);

            sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_MP));
            sendPacket(ActionFailed.STATIC_PACKET);
            return;
          }
          // If L2PcInstance have enough MP, the bow consummes it
          getStatus().reduceMp(mpConsume);

          // Set the period of bow non re-use
          _disableBowAttackEndTime = 5 * GameTimeController.TICKS_PER_SECOND + GameTimeController.getGameTicks();
        }
        else
        {
          // Cancel the action because the bow can't be re-use at this moment
          ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(CtrlEvent.EVT_READY_TO_ACT), 1000);

          sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }

      }
      else if(this instanceof L2NpcInstance)
      {
        if(_disableBowAttackEndTime > GameTimeController.getGameTicks())
          return;
      }
    }

    // Add the L2PcInstance to _knownObjects and _knownPlayer of the target
    target.getKnownList().addKnownObject(this);

    // Reduce the current CP if TIREDNESS configuration is activated
    if(Config.ALT_GAME_TIREDNESS)
    {
      setCurrentCp(getCurrentCp() - 10);
    }

    // Recharge any active auto soulshot tasks for player (or player's summon if one exists).
    if(this instanceof L2PcInstance)
    {
      ((L2PcInstance) this).rechargeAutoSoulShot(true, false, false);
    }
    else if(this instanceof L2Summon)
    {
      ((L2Summon) this).getOwner().rechargeAutoSoulShot(true, false, true);
    }

    // Verify if soulshots are charged.
    boolean wasSSCharged;

    if(this instanceof L2Summon && !(this instanceof L2PetInstance))
    {
      wasSSCharged = ((L2Summon) this).getChargedSoulShot() != L2ItemInstance.CHARGED_NONE;
    }
    else
    {
      wasSSCharged = weaponInst != null && weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE;
    }

   
    // Get the Attack Speed of the L2Character (delay (in milliseconds) before next attack)
    int timeAtk = calculateTimeBetweenAttacks(target, weaponItem);
    // the hit is calculated to happen halfway to the animation - might need further tuning e.g. in bow case
    int timeToHit = timeAtk / 2;
    _attackEndTime = GameTimeController.getGameTicks();
    _attackEndTime += (timeAtk / GameTimeController.MILLIS_IN_TICK);
    _attackEndTime -= 1;

    int ssGrade = 0;

    if(weaponItem != null)
    {
      ssGrade = weaponItem.getCrystalType();
    }

    // Create a Server->Client packet Attack
    Attack attack = new Attack(this, wasSSCharged, ssGrade);

    boolean hitted;

    // Set the Attacking Body part to CHEST
    setAttackingBodypart();

    // Heading calculation on every attack
    this.setHeading(Util.calculateHeadingFrom(this.getX(), this.getY(), target.getX(), target.getY()));
   
    // Get the Attack Reuse Delay of the L2Weapon
    int reuse = calculateReuseTime(target, weaponItem);

    // Select the type of attack to start
    if(weaponItem == null)
    {
      hitted = doAttackHitSimple(attack, target, timeToHit);
    }
    else if(weaponItem.getItemType() == L2WeaponType.BOW)
    {
      hitted = doAttackHitByBow(attack, target, timeAtk, reuse);
    }
    else if(weaponItem.getItemType() == L2WeaponType.POLE)
    {
      hitted = doAttackHitByPole(attack, timeToHit);
    }
    else if(isUsingDualWeapon())
    {
View Full Code Here

        activeSummon = null;
      }
     
      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
        {
          // 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.");
               */
            }
          }
         
          // 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.");
             */
          }
        }
       
        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.calcAtkBreak(target, damage))
        {
          target.breakAttack();
          target.breakCast();
        }
       
        // Maybe launch chance skills on us
        if (_chanceSkills != null)
        {
          _chanceSkills.onHit(target, false, crit);
        }
       
        // Maybe launch chance skills on target
        if (target.getChanceSkills() != null)
        {
          target.getChanceSkills().onHit(this, true, crit);
        }
       
        weapon = null;
      }
     
      // 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

          ThreadPoolManager.getInstance().executeTask(new QueuedMagicUseTask(currPlayer, queuedSkill.getSkill(), queuedSkill.isCtrlPressed(), queuedSkill.isShiftPressed()));
        }
       
        queuedSkill = null;
       
        final L2Weapon activeWeapon = getActiveWeaponItem();
        // Launch weapon Special ability skill effect if available
        if (activeWeapon != null)
        {
          try
          {
            if (targets != null && targets.length > 0)
            {
              for (L2Object target : targets)
              {
                if (target != null && target instanceof L2Character && !((L2Character) target).isDead())
                {
                  final L2Character player = (L2Character) target;
                 
                  if (activeWeapon.getSkillEffects(this, player, skill))
                  {
                    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

   *
   * @return the random damage multiplier
   */
  public final double getRandomDamageMultiplier()
  {
    L2Weapon activeWeapon = getActiveWeaponItem();
    int random;
   
    if (activeWeapon != null)
      random = activeWeapon.getRandomDamage();
    else
      random = 5+(int)Math.sqrt(getLevel());

    return (1+((double)Rnd.get(0-random,random)/100));
  }
View Full Code Here

    if(!(playable instanceof L2PcInstance))
      return;

    L2PcInstance activeChar = (L2PcInstance) playable;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    L2Weapon weaponItem = activeChar.getActiveWeaponItem();

    int itemId = item.getItemId();

    if(activeChar.isParalyzed())
    {
      activeChar.sendMessage("You Cannot Use This While You Are Paralyzed");
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if(activeChar.isInOlympiadMode())
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
      sm.addString(item.getItemName());
      activeChar.sendPacket(sm);
      sm = null;

      return;
    }

    // Check if Blessed Spiritshot can be used
    if(weaponInst == null || weaponItem.getSpiritShotCount() == 0)
    {
      if(!activeChar.getAutoSoulShot().containsKey(itemId))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
      }

      return;
    }

    // Check if Blessed Spiritshot is already active (it can be charged over Spiritshot)
    if(weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
      return;

    // Check for correct grade
    int weaponGrade = weaponItem.getCrystalType();
    if(weaponGrade == L2Item.CRYSTAL_NONE && itemId != 3947 || weaponGrade == L2Item.CRYSTAL_D && itemId != 3948 || weaponGrade == L2Item.CRYSTAL_C && itemId != 3949 || weaponGrade == L2Item.CRYSTAL_B && itemId != 3950 || weaponGrade == L2Item.CRYSTAL_A && itemId != 3951 || weaponGrade == L2Item.CRYSTAL_S && itemId != 3952)
    {
      if(!activeChar.getAutoSoulShot().containsKey(itemId))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
      }
      return;
    }

    // Consume Blessed Spiritshot if player has enough of them
    // TODO: test ss
    if(!Config.DONT_DESTROY_SS)
    {
      if(!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
      {
        if(activeChar.getAutoSoulShot().containsKey(itemId))
        {
          activeChar.removeAutoSoulShot(itemId);
          activeChar.sendPacket(new ExAutoSoulShot(itemId, 0));
View Full Code Here

    // Get the L2PcInstance corresponding to the thread
    L2PcInstance player = client.getActiveChar();
    if (player == null)
      return;
   
    L2Weapon currentWeapon = player.getActiveWeaponItem();
   
    // Check if the L2PcInstance is a GM
    if (player.getAccessLevel().isGm())
    {
      // Set the target of the L2PcInstance player
      player.setTarget(this);
     
      // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
      // The player.getLevel() - getLevel() permit to display the correct color in the select window
      MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
      player.sendPacket(my);
      my = null;
     
      // Check if the player is attackable (without a forced attack)
      if (isAutoAttackable(player))
      {
        // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
        StatusUpdate su = new StatusUpdate(getObjectId());
        su.addAttribute(StatusUpdate.CUR_HP, (int) getCurrentHp());
        su.addAttribute(StatusUpdate.MAX_HP, getMaxHp());
        player.sendPacket(su);
        su = null;
      }
     
      // Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance
      NpcHtmlMessage html = new NpcHtmlMessage(0);
      TextBuilder html1 = new TextBuilder("<html><body><center><font color=\"LEVEL\">NPC Information</font></center>");
      String className = getClass().getName().substring(43);
      html1.append("<br>");
     
      html1.append("Instance Type: " + className + "<br1>Faction: " + getFactionId() + "<br1>Location ID: " + (getSpawn() != null ? getSpawn().getLocation() : 0) + "<br1>");
     
      if (this instanceof L2ControllableMobInstance)
      {
        html1.append("Mob Group: " + MobGroupTable.getInstance().getGroupForMob((L2ControllableMobInstance) this).getGroupId() + "<br>");
      }
      else
      {
        html1.append("Respawn Time: " + (getSpawn() != null ? getSpawn().getRespawnDelay() / 1000 + "  Seconds<br>" : "?  Seconds<br>"));
      }
     
      html1.append("<table border=\"0\" width=\"100%\">");
      html1.append("<tr><td>Object ID</td><td>" + getObjectId() + "</td><td>NPC ID</td><td>" + getTemplate().npcId + "</td></tr>");
      html1.append("<tr><td>Castle</td><td>" + getCastle().getCastleId() + "</td><td>Coords</td><td>" + getX() + "," + getY() + "," + getZ() + "</td></tr>");
      html1.append("<tr><td>Level</td><td>" + getLevel() + "</td><td>Aggro</td><td>" + (this instanceof L2Attackable ? ((L2Attackable) this).getAggroRange() : 0) + "</td></tr>");
      html1.append("</table><br>");
     
      html1.append("<font color=\"LEVEL\">Combat</font>");
      html1.append("<table border=\"0\" width=\"100%\">");
      html1.append("<tr><td>Current HP</td><td>" + getCurrentHp() + "</td><td>Current MP</td><td>" + getCurrentMp() + "</td></tr>");
      html1.append("<tr><td>Max.HP</td><td>" + (int) (getMaxHp() / getStat().calcStat(Stats.MAX_HP, 1, this, null)) + "*" + getStat().calcStat(Stats.MAX_HP, 1, this, null) + "</td><td>Max.MP</td><td>" + getMaxMp() + "</td></tr>");
      html1.append("<tr><td>P.Atk.</td><td>" + getPAtk(null) + "</td><td>M.Atk.</td><td>" + getMAtk(null, null) + "</td></tr>");
      html1.append("<tr><td>P.Def.</td><td>" + getPDef(null) + "</td><td>M.Def.</td><td>" + getMDef(null, null) + "</td></tr>");
      html1.append("<tr><td>Accuracy</td><td>" + getAccuracy() + "</td><td>Evasion</td><td>" + getEvasionRate(null) + "</td></tr>");
      html1.append("<tr><td>Critical</td><td>" + getCriticalHit(null, null) + "</td><td>Speed</td><td>" + getRunSpeed() + "</td></tr>");
      html1.append("<tr><td>Atk.Speed</td><td>" + getPAtkSpd() + "</td><td>Cast.Speed</td><td>" + getMAtkSpd() + "</td></tr>");
      html1.append("</table><br>");
     
      html1.append("<font color=\"LEVEL\">Basic Stats</font>");
      html1.append("<table border=\"0\" width=\"100%\">");
      html1.append("<tr><td>STR</td><td>" + getSTR() + "</td><td>DEX</td><td>" + getDEX() + "</td><td>CON</td><td>" + getCON() + "</td></tr>");
      html1.append("<tr><td>INT</td><td>" + getINT() + "</td><td>WIT</td><td>" + getWIT() + "</td><td>MEN</td><td>" + getMEN() + "</td></tr>");
      html1.append("</table>");
     
      html1.append("<br><center><table><tr><td><button value=\"Edit NPC\" action=\"bypass -h admin_edit_npc " + getTemplate().npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><br1></td>");
      html1.append("<td><button value=\"Kill\" action=\"bypass -h admin_kill\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><br1></tr>");
      html1.append("<tr><td><button value=\"Show DropList\" action=\"bypass -h admin_show_droplist " + getTemplate().npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
      html1.append("<td><button value=\"Delete\" action=\"bypass -h admin_delete\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
      html1.append("<tr><td><button value=\"Show Skillist\" action=\"bypass -h admin_show_skilllist_npc " + getTemplate().npcId + "\" width=100 height=20 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td></td></tr>");
      html1.append("</table></center><br>");
      html1.append("</body></html>");
     
      html.setHtml(html1.toString());
      player.sendPacket(html);
      html = null;
      html1 = null;
      className = null;
    }
    else if (Config.ALT_GAME_VIEWNPC)
    {
      // Set the target of the L2PcInstance player
      player.setTarget(this);
     
      // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
      // The player.getLevel() - getLevel() permit to display the correct color in the select window
      MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
      player.sendPacket(my);
      my = null;
     
      // Check if the player is attackable (without a forced attack)
      if (isAutoAttackable(player))
      {
        // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
        StatusUpdate su = new StatusUpdate(getObjectId());
        su.addAttribute(StatusUpdate.CUR_HP, (int) getCurrentHp());
        su.addAttribute(StatusUpdate.MAX_HP, getMaxHp());
        player.sendPacket(su);
        su = null;
      }
     
      NpcHtmlMessage html = new NpcHtmlMessage(0);
      TextBuilder html1 = new TextBuilder("<html><body>");
     
      html1.append("<br><center><font color=\"LEVEL\">[Drop Info]</font></center>");
      html1.append("Rates legend: <font color=\"ff0000\">50%+</font> <font color=\"00ff00\">30%+</font> <font color=\"0000ff\">less than 30%</font>");
      html1.append("<table border=0 width=\"100%\">");
     
      for (final L2DropCategory cat : getTemplate().getDropData())
      {
        final FastList<L2DropData> drops = cat.getAllDrops();
        if (drops != null)
          for (final L2DropData drop : drops)
          {
            if (drop == null || ItemTable.getInstance().getTemplate(drop.getItemId()) == null)
            {
              continue;
            }
           
            String name = ItemTable.getInstance().getTemplate(drop.getItemId()).getName();
           
            if (drop.getChance() >= 600000)
            {
              html1.append("<tr><td><font color=\"ff0000\">" + name + "</font></td><td>" + (drop.isQuestDrop() ? "Quest" : cat.isSweep() ? "Sweep" : "Drop") + "</td></tr>");
            }
            else if (drop.getChance() >= 300000)
            {
              html1.append("<tr><td><font color=\"00ff00\">" + name + "</font></td><td>" + (drop.isQuestDrop() ? "Quest" : cat.isSweep() ? "Sweep" : "Drop") + "</td></tr>");
            }
            else
            {
              html1.append("<tr><td><font color=\"0000ff\">" + name + "</font></td><td>" + (drop.isQuestDrop() ? "Quest" : cat.isSweep() ? "Sweep" : "Drop") + "</td></tr>");
            }
          }
      }
     
      html1.append("</table>");
      html1.append("</body></html>");
     
      html.setHtml(html1.toString());
      player.sendPacket(html);
     
      html = null;
      html1 = null;
    }
    else
    // Like L2OFF set the target of the L2PcInstance player
    {
      // Check if the L2PcInstance already target the L2NpcInstance
      if (this != player.getTarget())
      {
        // Set the target of the L2PcInstance player
        player.setTarget(this);
       
        // Check if the player is attackable (without a forced attack)
        if (isAutoAttackable(player))
        {
          // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
          // The player.getLevel() - getLevel() permit to display the correct color in the select window
          MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
          player.sendPacket(my);
          my = null;
         
          // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
          StatusUpdate su = new StatusUpdate(getObjectId());
          su.addAttribute(StatusUpdate.CUR_HP, (int) getCurrentHp());
          su.addAttribute(StatusUpdate.MAX_HP, getMaxHp());
          player.sendPacket(su);
          su = null;
        }
        else
        {
          // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
          MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
          player.sendPacket(my);
          my = null;
        }
       
        player.setTimerToAttack(System.currentTimeMillis());
        player.sendPacket(new ValidateLocation(this));
      }
      else
      {
        player.sendPacket(new ValidateLocation(this));
        // Check if the player is attackable (without a forced attack) and isn't dead
        if (isAutoAttackable(player) && !isAlikeDead())
        {
          // Check the height difference
          if (Math.abs(player.getZ() - getZ()) < 400) // this max heigth difference might need some tweaking
          {
            // Like L2OFF player must not move with shift pressed
            // Only archer can hit from long
            if (!canInteract(player) && (currentWeapon != null && currentWeapon.getItemType() != L2WeaponType.BOW))
            {
              // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
              player.sendPacket(ActionFailed.STATIC_PACKET);
            }
            else if (!canInteract(player) && currentWeapon == null)
            {
              // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
              player.sendPacket(ActionFailed.STATIC_PACKET);
            }
            else
            {
              // Set the L2PcInstance Intention to AI_INTENTION_ATTACK
              player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
            }
          }
          else
          {
            // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
            player.sendPacket(ActionFailed.STATIC_PACKET);
          }
        }
        else if (!isAutoAttackable(player))
        {
          // Like L2OFF player must not move with shift pressed
          // Only archer can hit from long
          if (!canInteract(player) && (currentWeapon != null && currentWeapon.getItemType() != L2WeaponType.BOW))
          {
            // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
            player.sendPacket(ActionFailed.STATIC_PACKET);
          }
          else if (!canInteract(player) && currentWeapon == null)
View Full Code Here

    if(!(playable instanceof L2PcInstance))
      return;

    L2PcInstance activeChar = (L2PcInstance) playable;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    L2Weapon weaponItem = activeChar.getActiveWeaponItem();
    int itemId = item.getItemId();

    // Check if Soulshot can be used
    if(weaponInst == null || weaponItem.getSoulShotCount() == 0)
    {
      if(!activeChar.getAutoSoulShot().containsKey(itemId))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
      }
      return;
    }

    if(activeChar.isParalyzed())
    {
      activeChar.sendMessage("You Cannot Use This While You Are Paralyzed");
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Check for correct grade
    int weaponGrade = weaponItem.getCrystalType();
    if(weaponGrade == L2Item.CRYSTAL_NONE && itemId != 5789 && itemId != 1835 || weaponGrade == L2Item.CRYSTAL_D && itemId != 1463 || weaponGrade == L2Item.CRYSTAL_C && itemId != 1464 || weaponGrade == L2Item.CRYSTAL_B && itemId != 1465 || weaponGrade == L2Item.CRYSTAL_A && itemId != 1466 || weaponGrade == L2Item.CRYSTAL_S && itemId != 1467)
    {
      if(!activeChar.getAutoSoulShot().containsKey(itemId))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
      }
      return;
    }

    activeChar.soulShotLock.lock();
    try
    {
      // Check if Soulshot is already active
      if(weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
        return;

      // Consume Soulshots if player has enough of them
      int saSSCount = (int) activeChar.getStat().calcStat(Stats.SOULSHOT_COUNT, 0, null, null);
      int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;

      weaponItem = null;

      // TODO: test ss
      if(!Config.DONT_DESTROY_SS)
View Full Code Here

      }
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2Weapon weaponItem = player.getActiveWeaponItem();
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    if(weaponInst == null || weaponItem == null || weaponItem.getItemType() != L2WeaponType.ROD)
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
        activeChar.sendPacket(sm);
        sm = 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);
    weaponItem = null;
    if(player.getSkillLevel(1315) <= skill.getLevel()-2) //1315 - Fish Expertise
    {//Penalty
      player.sendPacket(new SystemMessage(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY));
View Full Code Here

TOP

Related Classes of com.l2jfrozen.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.