Package net.sf.l2j.gameserver.model.actor.instance

Examples of net.sf.l2j.gameserver.model.actor.instance.L2PcInstance$AIAccessor


       !(killerCharacter instanceof L2PetInstance) &&
       !(killerCharacter instanceof L2SummonInstance)) ||
      !isStarted())
      return;

    L2PcInstance killerPlayerInstance = null;

    if (killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2SummonInstance)
    {
      killerPlayerInstance = ((L2Summon)killerCharacter).getOwner();

      if (killerPlayerInstance == null)
        return;
    }
    else
      killerPlayerInstance = (L2PcInstance)killerCharacter;

    String playerName = killerPlayerInstance.getName();
    byte killerTeamId = getParticipantTeamId(playerName);

    playerName = killedPlayerInstance.getName();

    byte killedTeamId = getParticipantTeamId(playerName);
View Full Code Here


   @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  {
     if (!(activeChar instanceof L2PcInstance)) return; // currently not implemented for others
     L2PcInstance activePlayer = (L2PcInstance)activeChar;

     if (activePlayer.isInOlympiadMode())
     {
       activePlayer.sendPacket(new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
       return;
        }

     // Checks summoner not in arenas, siege zones, jail
         if (activePlayer.isInsideZone(L2Character.ZONE_PVP))
         {
           activePlayer.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_SUMMON_IN_COMBAT));
          return;
        }

        // check for summoner not in raid areas
         FastList<L2Object> objects = L2World.getInstance().getVisibleObjects(activeChar, 5000);

        if (objects != null)
        {
          for (L2Object object : objects)
          {
            if (object instanceof L2RaidBossInstance)
            {
              activePlayer.sendPacket(new SystemMessage(SystemMessageId.YOU_MAY_NOT_SUMMON_FROM_YOUR_CURRENT_LOCATION));
                    return;
            }
          }
        }

    try
        {
      for (int index = 0; index < targets.length; index++)
      {
        if (!(targets[index] instanceof L2Character))
          continue;

        L2Character target = (L2Character)targets[index];

        if (activeChar == target) continue;

                if (target instanceof L2PcInstance)
                {
                    L2PcInstance targetChar = (L2PcInstance)target;

                    // CHECK TARGET CONDITIONS

                    //This message naturally doesn't bring up a box...
                    //$s1 wishes to summon you from $s2. Do you accept?
            //SystemMessage sm2 = new SystemMessage(SystemMessageId.S1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT);
                  //sm2.addString(activeChar.getName());
                  //String nearestTown = MapRegionTable.getInstance().getClosestTownName(activeChar);
                  //sm2.addString(nearestTown);
                  //targetChar.sendPacket(sm2);

                    // is in same party (not necessary any more)
                    // if (!(targetChar.getParty() != null && targetChar.getParty().getPartyMembers().contains(activeChar)))
                    //  continue;

                    if (targetChar.isAlikeDead())
                    {
                      SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_DEAD_AT_THE_MOMENT_AND_CANNOT_BE_SUMMONED);
                      sm.addString(targetChar.getName());
                      activeChar.sendPacket(sm);
                      continue;
                    }

                    if (targetChar.isInStoreMode())
                    {
                      SystemMessage sm = new SystemMessage(SystemMessageId.S1_CURRENTLY_TRADING_OR_OPERATING_PRIVATE_STORE_AND_CANNOT_BE_SUMMONED);
                      sm.addString(targetChar.getName());
                      activeChar.sendPacket(sm);
                      continue;
                    }

                    // Target cannot be in combat (or dead, but that's checked by TARGET_PARTY)
                    if (targetChar.isRooted() || targetChar.isInCombat())
                    {
                      SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_ENGAGED_IN_COMBAT_AND_CANNOT_BE_SUMMONED);
                      sm.addString(targetChar.getName());
                      activeChar.sendPacket(sm);
                      continue;
                    }

                    // Check for the the target's festival status
                    if (targetChar.isInOlympiadMode()) {
                        activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_SUMMON_PLAYERS_WHO_ARE_IN_OLYMPIAD));
                        continue;
                    }

                    // Check for the the target's festival status
                    if (targetChar.isFestivalParticipant()) {
                      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
                        continue;
                    }

                    // Check for the target's jail status, arenas and siege zones
                    if (targetChar.isInsideZone(L2Character.ZONE_PVP))
                    {
                      activeChar.sendPacket(new SystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
                        continue;
                    }

                    // Requires a Summoning Crystal
                    if (targetChar.getInventory().getItemByItemId(8615) == null)
                    {
                      ((L2PcInstance)activeChar).sendMessage("Your target cannot be summoned while he hasn't got a Summoning Crystal");
                      targetChar.sendMessage("You cannot be summoned while you haven't got a Summoning Crystal");
                      continue;
                    }

                    if (!Util.checkIfInRange(0, activeChar, target, false))
                    {
                      targetChar.getInventory().destroyItemByItemId("Consume", 8615, 1, targetChar, activeChar);
                      targetChar.sendPacket(SystemMessage.sendString("You are summoned to a party member."));

                      targetChar.teleToLocation(activeChar.getX(),activeChar.getY(),activeChar.getZ(), true);
                    }
                    else
                    {

                    }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;


    // Alt game - Karma punishment
        if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && player.getKarma() > 0) return;

    L2Object target = player.getTarget();

        if(_count < 1)
        {
            sendPacket(new ActionFailed());
            return;
        }

        long subTotal = 0;
        int tax = 0;

      // Check for buylist validity and calculates summary values
        int slots = 0;
        int weight = 0;
        L2ManorManagerInstance manor = (target != null && target instanceof L2ManorManagerInstance) ? (L2ManorManagerInstance)target : null;


    for (int i = 0; i < _count; i++)
    {
      int itemId = _items[i * 2 + 0];
      int count  = _items[i * 2 + 1];
      int price = 0;
      if (count > Integer.MAX_VALUE)
      {
        Util.handleIllegalPlayerAction(player,"Warning!! Character "+player.getName()+" of account "+player.getAccountName()+" tried to purchase over "+Integer.MAX_VALUE+" items at the same time.",  Config.DEFAULT_PUNISH);
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        return;
      }

      L2Item template = ItemTable.getInstance().getTemplate(L2Manor.getInstance().getRewardItem(
          itemId,manor.getCastle().getCrop(itemId,CastleManorManager.PERIOD_CURRENT).getReward()));
          weight += count * template.getWeight();

      if (!template.isStackable()) slots += count;
      else if (player.getInventory().getItemByItemId(itemId) == null) slots++;
    }

    if (!player.getInventory().validateWeight(weight))
    {
      sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
      return;
    }


    if (!player.getInventory().validateCapacity(slots))
    {
      sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
      return;
    }

    // Proceed the purchase
    InventoryUpdate playerIU = new InventoryUpdate();
    _procureList =  manor.getCastle().getCropProcure(CastleManorManager.PERIOD_CURRENT);

    for (int i=0; i < _count; i++)
    {
      int itemId = _items[i * 2 + 0];
      int count  = _items[i * 2 + 1];
      if (count < 0) count = 0;

      int rewradItemId=L2Manor.getInstance().getRewardItem(
          itemId,manor.getCastle().getCrop(itemId, CastleManorManager.PERIOD_CURRENT).getReward());

      int rewradItemCount = 1; //L2Manor.getInstance().getRewardAmount(itemId, manor.getCastle().getCropReward(itemId));

      rewradItemCount = count / rewradItemCount;

      // Add item to Inventory and adjust update packet
      L2ItemInstance item = player.getInventory().addItem("Manor",rewradItemId,rewradItemCount,player,manor);
      L2ItemInstance iteme = player.getInventory().destroyItemByItemId("Manor",itemId,count,player,manor);

      if (item == null || iteme == null)
        continue;

      playerIU.addRemovedItem(iteme);
      if (item.getCount() > rewradItemCount) playerIU.addModifiedItem(item);
      else playerIU.addNewItem(item);

      // Send Char Buy Messages
      SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
      sm.addItemName(rewradItemId);
      sm.addNumber(rewradItemCount);
      player.sendPacket(sm);
      sm = null;

      //manor.getCastle().setCropAmount(itemId, manor.getCastle().getCrop(itemId, CastleManorManager.PERIOD_CURRENT).getAmount() - count);
    }

    // Send update packets
    player.sendPacket(playerIU);

    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
    player.sendPacket(su);
  }
View Full Code Here

    else if (command.startsWith("admin_setteam"))
    {
      String val = command.substring(14);
      int teamVal = Integer.parseInt(val);
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (target instanceof L2PcInstance)
        player = (L2PcInstance)target;
      else
        return false;
      player.setTeam(teamVal);
      if (teamVal != 0)
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
        sm.addString("You have joined team " + teamVal);
        player.sendPacket(sm);
      }
      player.broadcastUserInfo();
    }
    else if (command.startsWith("admin_social"))
    {
      try
      {
        String target=null;
        L2Object obj = activeChar.getTarget();
        if (st.countTokens() == 2)
        {
          int social = Integer.parseInt(st.nextToken());
          target = st.nextToken();
          if (target != null)
          {
            L2PcInstance player = L2World.getInstance().getPlayer(target);
            if (player != null)
            {
              if (performSocial(social,player,activeChar))
                activeChar.sendMessage(player.getName()+" was affected by your request.");
            }
            else
            {
              try
              {
                int radius = Integer.parseInt(target);
                for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
                  if (activeChar.isInsideRadius(object, radius, false, false))
                    performSocial(social,object,activeChar);
                activeChar.sendMessage(radius+ " units radius affected by your request.");
              }
              catch (NumberFormatException nbe)
              {
                activeChar.sendMessage("Incorrect parameter");
              }
            }
          }
        }
        else if (st.countTokens() == 1)
        {
          int social = Integer.parseInt(st.nextToken());
          if (obj == null)
            obj = activeChar;
         
          if (performSocial(social,obj,activeChar))
            activeChar.sendMessage(obj.getName()+ " was affected by your request.");
          else
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
        }
        else if (!command.contains("menu"))
          activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
      }
      catch (Exception e)
      {
        if (Config.DEBUG)
          e.printStackTrace();
      }
    }
    else if (command.startsWith("admin_abnormal"))
    {
      try
      {
        String target=null;
        L2Object obj = activeChar.getTarget();
        if (st.countTokens() == 2)
        {
          String parm = st.nextToken();
          int abnormal = Integer.decode("0x"+parm);
          target = st.nextToken();
          if (target != null)
          {
            L2PcInstance player = L2World.getInstance().getPlayer(target);
            if (player != null)
            {
              if (performAbnormal(abnormal,player))
                activeChar.sendMessage(player.getName()+"'s abnormal status was affected by your request.");
              else
                activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
            }
            else
            {
View Full Code Here

                        if (!nearbyPlayers.isEmpty())
                        {
                            int randomPlayerIndex = Rnd.nextInt(nearbyPlayers.size());

                            L2PcInstance randomPlayer = nearbyPlayers.get(randomPlayerIndex);

                            final int winningCabal = SevenSigns.getInstance().getCabalHighestScore();
                            int losingCabal = SevenSigns.CABAL_NULL;

                            if (winningCabal == SevenSigns.CABAL_DAWN) losingCabal = SevenSigns.CABAL_DUSK;
                            else if (winningCabal == SevenSigns.CABAL_DUSK)
                                losingCabal = SevenSigns.CABAL_DAWN;

                            if (text.indexOf("%player_random%") > -1)
                                text = text.replaceAll("%player_random%", randomPlayer.getName());

                            if (text.indexOf("%player_cabal_winner%") > -1)
                            {
                                for (L2PcInstance nearbyPlayer : nearbyPlayers)
                                {
View Full Code Here

        if (activeChar.isAlikeDead()) return;
        for (L2Object target : targets)
        {
          if (target instanceof L2PcInstance)
          {
            L2PcInstance trg = (L2PcInstance)target;
            if (trg.isAlikeDead()) continue;
            //trg.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), true);
            trg.setXYZ(activeChar.getX()+Rnd.get(-10,10), activeChar.getY()+Rnd.get(-10,10), activeChar.getZ());
            trg.sendPacket(new ValidateLocation(trg));
          }
        }
    }
View Full Code Here

          {
            _log.fine("selected slot:" + _charSlot);
          }

          //load up character from disk
          L2PcInstance cha = getClient().loadCharFromDisk(_charSlot);
          if (cha == null)
          {
            _log.severe("Character could not be loaded (slot:"+_charSlot+")");
            sendPacket(new ActionFailed());
            return;
          }
          if (cha.getAccessLevel() < 0)
          {
            cha.closeNetConnection();
            return;
          }

          cha.setClient(getClient());
          getClient().setActiveChar(cha);

          getClient().setState(GameClientState.IN_GAME);
          CharSelected cs = new CharSelected(cha, getClient().getSessionId().playOkID1);
          sendPacket(cs);
View Full Code Here

        if (soul && weapon != null)
                weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
        if(skill.getDmgDirectlyToHP() && target instanceof L2PcInstance)
            {
          L2PcInstance player = (L2PcInstance)target;
              if (!player.isInvul())
          {
                   if (damage >= player.getCurrentHp())
                   {
                     if(player.isInDuel()) player.setCurrentHp(1);
                     else
                     {
                       player.setCurrentHp(0);
                       if (player.isInOlympiadMode())
                       {
                         player.abortAttack();
                         player.abortCast();
                         player.getStatus().stopHpMpRegeneration();
                       }
                       else
                         player.doDie(activeChar);
                     }
                   }
                   else
                    player.setCurrentHp(player.getCurrentHp() - damage);
          }
              SystemMessage smsg = new SystemMessage(SystemMessageId.S1_GAVE_YOU_S2_DMG);
              smsg.addString(activeChar.getName());
              smsg.addNumber((int)damage);
              player.sendPacket(smsg);
            }
            else
              target.reduceCurrentHp(damage, activeChar);
        if(activeChar instanceof L2PcInstance)
          activeChar.sendPacket(new SystemMessage(SystemMessageId.CRITICAL_HIT));
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_DID_S1_DMG);
              sm.addNumber((int)damage);
              activeChar.sendPacket(sm);
      }
      //Possibility of a lethal strike
      if(!target.isRaid()
          && !(target instanceof L2DoorInstance)
          && !(target instanceof L2NpcInstance && ((L2NpcInstance)target).getNpcId() == 35062))
      {
        int chance = Rnd.get(100);
        //2nd lethal effect activate (cp,hp to 1 or if target is npc then hp to 1)
        if(skill.getLethalChance2() > 0 && chance < Formulas.getInstance().calcLethal(activeChar, target, skill.getLethalChance2()))
              {
                if (target instanceof L2NpcInstance)
                        target.reduceCurrentHp(target.getCurrentHp()-1, activeChar);
              else if (target instanceof L2PcInstance) // If is a active player set his HP and CP to 1
              {
                L2PcInstance player = (L2PcInstance)target;
                if (!player.isInvul()){
                  player.setCurrentHp(1);
                player.setCurrentCp(1);
                }
              }
                activeChar.sendPacket(new SystemMessage(SystemMessageId.LETHAL_STRIKE));
              }
              else if(skill.getLethalChance1() > 0 && chance < Formulas.getInstance().calcLethal(activeChar, target, skill.getLethalChance1())){
                if (target instanceof L2PcInstance)
                  {
                  L2PcInstance player = (L2PcInstance)target;
                if (!player.isInvul())
                  player.setCurrentCp(1); // Set CP to 1
                  }
                else if (target instanceof L2NpcInstance) // If is a monster remove first damage and after 50% of current hp
                  target.reduceCurrentHp(target.getCurrentHp()/2, activeChar);
                activeChar.sendPacket(new SystemMessage(SystemMessageId.LETHAL_STRIKE));
        }
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2PcInstance activeChar = getClient().getActiveChar();
        if(activeChar == null)
            return;

        if (Config.ALT_PRIVILEGES_ADMIN && !AdminCommandHandler.getInstance().checkPrivileges(activeChar,"admin_"+_command))
            return;

        if(!activeChar.isGM() && !"gm".equalsIgnoreCase(_command))
        {
          Util.handleIllegalPlayerAction(activeChar,"Warning!! Non-gm character "+activeChar.getName()+" requests gm bypass handler, hack?", Config.DEFAULT_PUNISH);
          return;
        }

    IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler("admin_"+_command);
View Full Code Here

      *
      * @param lastAttacker The L2Character that has killed the L2Attackable
      */
     public void doEventDrop(L2Character lastAttacker)
     {
         L2PcInstance player = null;
         if (lastAttacker instanceof L2PcInstance)
             player = (L2PcInstance)lastAttacker;
         else if (lastAttacker instanceof L2Summon)
             player = ((L2Summon)lastAttacker).getOwner();

         if (player == null) return; // Don't drop anything if the last attacker or owner isn't L2PcInstance

         if (player.getLevel() - getLevel() > 9) return;

         // Go through DateDrop of EventDroplist allNpcDateDrops within the date range
         for (DateDrop drop : EventDroplist.getInstance().getAllDrops())
         {
             if (Rnd.get(L2DropData.MAX_CHANCE) < drop.chance)
             {
                 RewardItem item = new RewardItem(drop.items[Rnd.get(drop.items.length)], Rnd.get(drop.min, drop.max));
                 if (Config.AUTO_LOOT) player.doAutoLoot(this, item); // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
                 else DropItem(player, item); // drop the item on the ground
             }
         }
     }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.actor.instance.L2PcInstance$AIAccessor

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.