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

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


  public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  {

    int itemId = item.getItemId();
    if (!(playable instanceof L2PcInstance)) return;
    L2PcInstance activeChar = (L2PcInstance) playable;
    L2Object target = activeChar.getTarget();

    if (!(target instanceof L2DoorInstance))
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      activeChar.sendPacket(new ActionFailed());
      return;
    }
    L2DoorInstance door = (L2DoorInstance)target;

    if (!(activeChar.isInsideRadius(door, INTERACTION_DISTANCE, false, false)))
    {
      activeChar.sendMessage("Too far.");
      activeChar.sendPacket(new ActionFailed());
      return;
    }
    if (activeChar.getAbnormalEffect() > 0 || activeChar.isInCombat())
    {
      activeChar.sendMessage("You cannot use the key now.");
      activeChar.sendPacket(new ActionFailed());
      return;
    }

    int openChance = 35;

    if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false)) return;

    switch (itemId){
    case 8273: //AnteroomKey
        if (door.getDoorName().startsWith("Anteroom")){
                  if (openChance > 0 && Rnd.get(100) < openChance) {
                    activeChar.sendMessage("You opened Anterooms Door.");
                    door.openMe();
                    door.onOpen(); // Closes the door after 60sec
                    activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 3));
                  }
                  else {
                    //test with: activeChar.sendPacket(new SystemMessage(SystemMessage.FAILED_TO_UNLOCK_DOOR));
                    activeChar.sendMessage("You failed to open Anterooms Door.");
                    activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 13));
                PlaySound playSound = new PlaySound("interfacesound.system_close_01");
                activeChar.sendPacket(playSound);
                  }
        }
        else{
          activeChar.sendMessage("Incorrect Door.");
        }
        break;
    case 8274: //Chapelkey, Capel Door has a Gatekeeper?? I use this key for Altar Entrance
      if (door.getDoorName().startsWith("Altar_Entrance")){
              if (openChance > 0 && Rnd.get(100) < openChance) {
                activeChar.sendMessage("You opened Altar Entrance.");
                door.openMe();
                door.onOpen();
                activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 3));
              }
              else {
                activeChar.sendMessage("You failed to open Altar Entrance.");
                activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 13));
            PlaySound playSound = new PlaySound("interfacesound.system_close_01");
            activeChar.sendPacket(playSound);
              }
            }
      else{
        activeChar.sendMessage("Incorrect Door.");
      }
      break;
    case 8275: //Key of Darkness
      if (door.getDoorName().startsWith("Door_of_Darkness")){
              if (openChance > 0 && Rnd.get(100) < openChance) {
                activeChar.sendMessage("You opened Door of Darkness.");
                door.openMe();
                door.onOpen();
                activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 3));
              }
              else {
                activeChar.sendMessage("You failed to open Door of Darkness.");
                activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 13));
            PlaySound playSound = new PlaySound("interfacesound.system_close_01");
            activeChar.sendPacket(playSound);
              }
            }
      else{
        activeChar.sendMessage("Incorrect Door.");
      }
      break;
    }
  }
View Full Code Here


  }

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

    player.getSellList().setTitle(_storeMsg);
    sendPacket(new PrivateStoreMsgSell(player));
  }
View Full Code Here

  }

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

        if ((SevenSigns.getInstance().isSealValidationPeriod() || SevenSigns.getInstance().isCompResultsPeriod()) && _page == 4)
            return;

    SSQStatus ssqs = new SSQStatus(activeChar, _page);
    activeChar.sendPacket(ssqs);
  }
View Full Code Here

  @Override
  public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  {
    int itemId = item.getItemId();

    L2PcInstance activeChar;

    if (playable instanceof L2PcInstance)
      activeChar = (L2PcInstance)playable;
    else if (playable instanceof L2PetInstance)
      activeChar = ((L2PetInstance)playable).getOwner();
    else
      return;

    if (activeChar.isAllSkillsDisabled())
    {
            ActionFailed af = new ActionFailed();
            activeChar.sendPacket(af);
      return;
    }

    switch (itemId) {
    case 5235:
      activeChar.getAppearance().setFace(0);
      break;
    case 5236:
      activeChar.getAppearance().setFace(1);
      break;
    case 5237:
      activeChar.getAppearance().setFace(2);
      break;
    case 5238:
      activeChar.getAppearance().setHairColor(0);
      break;
    case 5239:
      activeChar.getAppearance().setHairColor(1);
      break;
    case 5240:
      activeChar.getAppearance().setHairColor(2);
      break;
    case 5241:
      activeChar.getAppearance().setHairColor(3);
      break;
    case 5242:
      activeChar.getAppearance().setHairStyle(0);
      break;
    case 5243:
      activeChar.getAppearance().setHairStyle(1);
      break;
    case 5244:
      activeChar.getAppearance().setHairStyle(2);
      break;
    case 5245:
      activeChar.getAppearance().setHairStyle(3);
      break;
    case 5246:
      activeChar.getAppearance().setHairStyle(4);
      break;
    case 5247:
      activeChar.getAppearance().setHairStyle(5);
      break;
    case 5248:
      activeChar.getAppearance().setHairStyle(6);
      break;
    }

        // Create a summon effect!
        MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2003, 1, 1, 0);
        activeChar.broadcastPacket(MSU);

    // Update the changed stat for the character in the DB.
    activeChar.store();

        // Remove the item from inventory.
    activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);

    // Broadcast the changes to the char and all those nearby.
    UserInfo ui = new UserInfo(activeChar);
    activeChar.broadcastPacket(ui);
  }
View Full Code Here

  @Override
  protected final void writeImpl()
  {
    writeC(0x4e);
    L2PcInstance player =  getClient().getActiveChar();
        writeD(_partyMembers.get(0).getObjectId()); // c3 party leader id
        writeD(_partyMembers.get(0).getParty().getLootDistribution());//c3 party loot type (0,1,2,....)
    writeD(_partyMembers.size()-1);

    for(int i = 0; i < _partyMembers.size(); i++)
    {
      L2PcInstance member = _partyMembers.get(i);
      if (!member.equals(player))
      {
        writeD(member.getObjectId());
        writeS(member.getName());

        writeD((int) member.getCurrentCp()); //c4
        writeD(member.getMaxCp()); //c4

        writeD((int) member.getCurrentHp());
        writeD(member.getMaxHp());
        writeD((int) member.getCurrentMp());
        writeD(member.getMaxMp());
        writeD(member.getLevel());
        writeD(member.getClassId().getId());
        writeD(0);//writeD(0x01); ??
        writeD(0);
      }
    }
  }
View Full Code Here

    // teleport all participants to there team spot
    for (TvTEventTeam team : _teams)
    {
      for (String playerName : team.getParticipatedPlayerNames())
      {
        L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);

        if (playerInstance == null)
          continue;

        // implements Runnable and starts itself in constructor
View Full Code Here

    byte teamId = (byte)(_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
    TvTEventTeam team = _teams[teamId];

    for (String playerName : team.getParticipatedPlayerNames())
    {
      L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);

      for (int[] reward : Config.TVT_EVENT_REWARDS)
      {
        if (playerInstance == null)
          continue;

        PcInventory inv = playerInstance.getInventory();

        if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
          inv.addItem("TvT Event", reward[0], reward[1], playerInstance, playerInstance);
        else
        {
          for (int i=0;i<reward[1];i++)
            inv.addItem("TvT Event", reward[0], 1, playerInstance, playerInstance);
        }

        SystemMessage systemMessage = null;

        if (reward[1] > 1)
        {
          systemMessage = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
          systemMessage.addItemName(reward[0]);
          systemMessage.addNumber(reward[1]);
        }
        else
        {
          systemMessage = new SystemMessage(SystemMessageId.EARNED_ITEM);
          systemMessage.addItemName(reward[0]);
        }

        playerInstance.sendPacket(systemMessage);
      }

      StatusUpdate statusUpdate = new StatusUpdate(playerInstance.getObjectId());

      statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
      playerInstance.sendPacket(statusUpdate);

      NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);

      npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
      playerInstance.sendPacket(npcHtmlMessage);
    }

    return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
  }
View Full Code Here

  }

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

        // You cannot do anything else while fishing
        if (activeChar.isFishing())
        {
            SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
            activeChar.sendPacket(sm);
            sm = null;
            return;
        }

        // check if its the actionId is allowed
        if (_actionId < 2 || _actionId > 13)
        {
          Util.handleIllegalPlayerAction(activeChar, "Warning!! Character "+activeChar.getName()+" of account "+activeChar.getAccountName()+" requested an internal Social Action.", Config.DEFAULT_PUNISH);
          return;
        }

    if activeChar.getPrivateStoreType()==0 &&
        activeChar.getActiveRequester()==null &&
        !activeChar.isAlikeDead() &&
        (!activeChar.isAllSkillsDisabled() || activeChar.isInDuel()) &&
        activeChar.getAI().getIntention()==CtrlIntention.AI_INTENTION_IDLE)
    {
      if (Config.DEBUG) _log.fine("Social Action:" + _actionId);

      SocialAction atk = new SocialAction(activeChar.getObjectId(), _actionId);
      activeChar.broadcastPacket(atk);
      /*
      // Schedule a social task to wait for the animation to finish
      ThreadPoolManager.getInstance().scheduleGeneral(new SocialTask(this), 2600);
      activeChar.setIsParalyzed(true);
      */
 
View Full Code Here

    for (TvTEventTeam team : _teams)
    {
      for (String playerName : team.getParticipatedPlayerNames())
      {
        L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);

        if (playerInstance == null)
          continue;

        new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
View Full Code Here

  public static boolean onAction(String playerName, String targetPlayerName)
  {
    if (!isStarted())
      return true;

    L2PcInstance playerInstance = L2World.getInstance().getPlayer(playerName);

    if (playerInstance == null)
      return false;

    if (playerInstance.isGM())
      return true;

    byte playerTeamId = getParticipantTeamId(playerName);
    byte targetPlayerTeamId = getParticipantTeamId(targetPlayerName);
View Full Code Here

TOP

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

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.