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

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


  @Override
  public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  {
    if (!(playable instanceof L2PcInstance))
      return;
    L2PcInstance activeChar = (L2PcInstance)playable;
      int itemId = item.getItemId();
    if (itemId == 5562) { //crystal_carol_01
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2140, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_01");
    }
    else if (itemId == 5563) { //crystal_carol_02
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2141, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_02");
    }
    else if (itemId == 5564) { //crystal_carol_03
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2142, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_03");
    }
    else if (itemId == 5565) { //crystal_carol_04
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2143, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_04");
    }
    else if (itemId == 5566) { //crystal_carol_05
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2144, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_05");
    }
    else if (itemId == 5583) { //crystal_carol_06
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2145, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_06");
    }
    else if (itemId == 5584) { //crystal_carol_07
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2146, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_07");
    }
    else if (itemId == 5585) { //crystal_carol_08
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2147, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_08");
    }
    else if (itemId == 5586) { //crystal_carol_09
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2148, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_09");
    }
    else if (itemId == 5587) { //crystal_carol_10
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2149, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_carol_10");
    }
    else if (itemId == 4411) { //crystal_journey
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2069, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_journey");
    }
    else if (itemId == 4412) { //crystal_battle
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2068, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_battle");
    }
    else if (itemId == 4413) { //crystal_love
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2070, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_love");
    }
    else if (itemId == 4414) { //crystal_solitude
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2072, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_solitude");
    }
    else if (itemId == 4415) { //crystal_festival
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2071, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_festival");
    }
    else if (itemId == 4416) { //crystal_celebration
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2073, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_celebration");
    }
    else if (itemId == 4417) { //crystal_comedy
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2067, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_comedy");
    }
    else if (itemId == 5010) { //crystal_victory
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2066, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_victory");
    }
    else if (itemId == 6903) { //music_box_m
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2187, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"EtcSound.battle");
    }
    else if (itemId == 7061) { //crystal_birthday
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2073, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound2.crystal_celebration");
    }
    else if (itemId == 7062) { //crystal_wedding
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2230, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"SkillSound5.wedding");
    }
    else if (itemId == 8555) { //VVKorea
      MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2272, 1, 1, 0);
      activeChar.broadcastPacket(MSU);
      //playCrystalSound(activeChar,"EtcSound.VVKorea");
    }
    activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
  }
View Full Code Here


                else
                    getActiveChar().sendPacket(new NpcInfo(summon, getActiveChar()));
            }
            else if (object instanceof L2PcInstance)
            {
                L2PcInstance otherPlayer = (L2PcInstance) object;
                if(otherPlayer.isInBoat())
                {
                  otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getPosition().getWorldPosition());
                  getActiveChar().sendPacket(new CharInfo(otherPlayer));
                  int relation = otherPlayer.getRelation(getActiveChar());
                  if (otherPlayer.getKnownList().getKnownRelations().get(getActiveChar().getObjectId()) != null && otherPlayer.getKnownList().getKnownRelations().get(getActiveChar().getObjectId()) != relation)
                    getActiveChar().sendPacket(new RelationChanged(otherPlayer, relation, getActiveChar().isAutoAttackable(otherPlayer)));
                  getActiveChar().sendPacket(new GetOnVehicle(otherPlayer, otherPlayer.getBoat(), otherPlayer.getInBoatPosition().getX(), otherPlayer.getInBoatPosition().getY(), otherPlayer.getInBoatPosition().getZ()));
                  /*if(otherPlayer.getBoat().GetVehicleDeparture() == null)
                  {

                    int xboat = otherPlayer.getBoat().getX();
                    int yboat= otherPlayer.getBoat().getY();
                    double modifier = Math.PI/2;
                    if (yboat == 0)
                    {
                      yboat = 1;
                    }
                    if(yboat < 0)
                    {
                      modifier = -modifier;
                    }
                    double angleboat = modifier - Math.atan(xboat/yboat);
                    int xp = otherPlayer.getX();
                    int yp = otherPlayer.getY();
                    modifier = Math.PI/2;
                    if (yp == 0)
                    {
                      yboat = 1;
                    }
                    if(yboat < 0)
                    {
                      modifier = -modifier;
                    }
                    double anglep = modifier - Math.atan(yp/xp);

                    double finx = Math.cos(anglep - angleboat)*Math.sqrt(xp *xp +yp*yp ) + Math.cos(angleboat)*Math.sqrt(xboat *xboat +yboat*yboat );
                    double finy = Math.sin(anglep - angleboat)*Math.sqrt(xp *xp +yp*yp ) + Math.sin(angleboat)*Math.sqrt(xboat *xboat +yboat*yboat );
                    //otherPlayer.getPosition().setWorldPosition(otherPlayer.getBoat().getX() - otherPlayer.getInBoatPosition().x,otherPlayer.getBoat().getY() - otherPlayer.getInBoatPosition().y,otherPlayer.getBoat().getZ()- otherPlayer.getInBoatPosition().z);
                    otherPlayer.getPosition().setWorldPosition((int)finx,(int)finy,otherPlayer.getBoat().getZ()- otherPlayer.getInBoatPosition().z);

                  }*/
                }
                else
                {
                  getActiveChar().sendPacket(new CharInfo(otherPlayer));
                  int relation = otherPlayer.getRelation(getActiveChar());
                  if (otherPlayer.getKnownList().getKnownRelations().get(getActiveChar().getObjectId()) != null && otherPlayer.getKnownList().getKnownRelations().get(getActiveChar().getObjectId()) != relation)
                    getActiveChar().sendPacket(new RelationChanged(otherPlayer, relation, getActiveChar().isAutoAttackable(otherPlayer)));
                }

                if (otherPlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_SELL)
                  getActiveChar().sendPacket(new PrivateStoreMsgSell(otherPlayer));
                else if (otherPlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_BUY)
                  getActiveChar().sendPacket(new PrivateStoreMsgBuy(otherPlayer));
                else if (otherPlayer.getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_MANUFACTURE)
                  getActiveChar().sendPacket(new RecipeShopMsg(otherPlayer));            }

            if (object instanceof L2Character)
            {
                // Update the state of the L2Character object client side by sending Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance
View Full Code Here

    L2Object target = activeChar.getTarget();

    if (!(target instanceof L2PcInstance))
      return;

    L2PcInstance player = (L2PcInstance)target;
    StringTokenizer st = new StringTokenizer(modifications);

    if (st.countTokens() != 6) {
      editCharacter(player);
      return;
    }

    String hp = st.nextToken();
    String mp = st.nextToken();
    String cp = st.nextToken();
    String pvpflag = st.nextToken();
    String pvpkills = st.nextToken();
    String pkkills = st.nextToken();

    int hpval = Integer.parseInt(hp);
    int mpval = Integer.parseInt(mp);
    int cpval = Integer.parseInt(cp);
    int pvpflagval = Integer.parseInt(pvpflag);
    int pvpkillsval = Integer.parseInt(pvpkills);
    int pkkillsval = Integer.parseInt(pkkills);

    //Common character information
    player.sendMessage("Admin has changed your stats." +
        "  HP: " + hpval + "  MP: " + mpval + "  CP: " + cpval +
        "  PvP Flag: " + pvpflagval + " PvP/PK " + pvpkillsval + "/" + pkkillsval);
    player.setCurrentHp(hpval);
    player.setCurrentMp(mpval);
    player.setCurrentCp(cpval);
    player.setPvpFlag(pvpflagval);
    player.setPvpKills(pvpkillsval);
    player.setPkKills(pkkillsval);

    // Save the changed parameters to the database.
    player.store();

    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_HP, hpval);
    su.addAttribute(StatusUpdate.MAX_HP, player.getMaxHp());
    su.addAttribute(StatusUpdate.CUR_MP, mpval);
    su.addAttribute(StatusUpdate.MAX_MP, player.getMaxMp());
    su.addAttribute(StatusUpdate.CUR_CP, cpval);
    su.addAttribute(StatusUpdate.MAX_CP, player.getMaxCp());
    player.sendPacket(su);

    //Admin information
    player.sendMessage("Changed stats of " + player.getName() + "." +
        "  HP: " + hpval + "  MP: " + mpval + "  CP: " + cpval +
        "  PvP: " + pvpflagval + " / " + pvpkillsval );

    if (Config.DEBUG)
      _log.fine("[GM]"+activeChar.getName()+" changed stats of "+player.getName()+". " +
          " HP: "+hpval+" MP: "+mpval+" CP: " + cpval +
          " PvP: "+pvpflagval+" / "+pvpkillsval);

    showCharacterInfo(activeChar, null); //Back to start

    player.broadcastPacket(new CharInfo(player));
    player.sendPacket(new UserInfo(player));
    player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
    player.decayMe();
    player.spawnMe(activeChar.getX(),activeChar.getY(),activeChar.getZ());
  }
View Full Code Here

    }

    @Override
  protected void runImpl()
    {
        L2PcInstance player = getClient().getActiveChar();
        if (player == null)
        {
            return;
        }
    if (player.getClan() == null)
        {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
            return;
        }
    if (!player.isClanLeader())
    {
      player.sendPacket(new SystemMessage(SystemMessageId.ONLY_CLAN_LEADER_WITHDRAW_ALLY));
      return;
    }
        L2Clan clan = player.getClan();
    if (clan.getAllyId() == 0)
    {
      player.sendPacket(new SystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES));
      return;
    }
    if (clan.getClanId() == clan.getAllyId())
    {
      player.sendPacket(new SystemMessage(SystemMessageId.ALLIANCE_LEADER_CANT_WITHDRAW));
      return;
    }

    long currentTime = System.currentTimeMillis();
        clan.setAllyId(0);
        clan.setAllyName(null);
        clan.setAllyPenaltyExpiryTime(
            currentTime + Config.ALT_ALLY_JOIN_DAYS_WHEN_LEAVED * 86400000L,
            L2Clan.PENALTY_TYPE_CLAN_LEAVED); //24*60*60*1000 = 86400000
        clan.updateClanInDB();

        player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_ALLIANCE));
    }
View Full Code Here

  }

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

      if (activeChar.getAllyId() == 0)
      {
          _cha.sendPacket(new SystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES));
            return;
      }
View Full Code Here

  private void editCharacter(L2PcInstance activeChar)
  {
    L2Object target = activeChar.getTarget();
    if (!(target instanceof L2PcInstance))
      return;
    L2PcInstance player = (L2PcInstance)target;
    gatherCharacterInfo(activeChar, player,"charedit.htm");
  }
View Full Code Here

  {
    if (characterName.matches(Config.CNAME_TEMPLATE))
    {
      String account=null;
      Map<Integer, String> chars;
      L2PcInstance player = L2World.getInstance().getPlayer(characterName);
      if (player == null)
        throw new IllegalArgumentException("Player doesn't exist");
      chars=player.getAccountChars();
      account = player.getAccountName();
      TextBuilder replyMSG = new TextBuilder();
      NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
      adminReply.setFile("data/html/admin/accountinfo.htm");
      for (String charname : chars.values())
        replyMSG.append(charname+"<br1>");
View Full Code Here

    @Override
  public void useItem(L2PlayableInstance playable, L2ItemInstance item)
    {
      if(!(playable instanceof L2PcInstance)) return; // prevent Class cast exception
        L2PcInstance activeChar = (L2PcInstance)playable;
        int itemId = item.getItemId();

        if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_FIREWORK))
        {
          SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
          sm.addItemName(itemId);
          activeChar.sendPacket(sm);
          return;
        }

        /*
         * Elven Firecracker
         */
        if (itemId == 6403) // elven_firecracker, xml: 2023
        {
            MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2023, 1, 1, 0);
            activeChar.sendPacket(MSU);
            activeChar.broadcastPacket(MSU);
            useFw(activeChar, 2023, 1);
            playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
        }
          /*
         * Firework
         */
        else if (itemId == 6406) // firework, xml: 2024
        {
            MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2024, 1, 1, 0);
            activeChar.sendPacket(MSU);
            activeChar.broadcastPacket(MSU);
            useFw(activeChar, 2024, 1);
            playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
        }
        /*
         * Lage Firework
         */
        else if (itemId == 6407) // large_firework, xml: 2025
        {
            MagicSkillUser MSU = new MagicSkillUser(playable, activeChar, 2025, 1, 1, 0);
            activeChar.sendPacket(MSU);
            activeChar.broadcastPacket(MSU);
            useFw(activeChar, 2025, 1);
            playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
        }
    }
View Full Code Here

  }

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

    if (activeChar == null)
      return;

    SystemMessage sm;
    java.sql.Connection con = null;

    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      PreparedStatement statement = con.prepareStatement("SELECT friend_id, friend_name FROM character_friends WHERE char_id=?");
      statement.setInt(1, activeChar.getObjectId());

      ResultSet rset = statement.executeQuery();

      //======<Friend List>======
      activeChar.sendPacket(new SystemMessage(SystemMessageId.FRIEND_LIST_HEAD));

            L2PcInstance friend = null;
      while (rset.next())
      {
        // int friendId = rset.getInt("friend_id");
        String friendName = rset.getString("friend_name");
        friend = L2World.getInstance().getPlayer(friendName);
View Full Code Here

        if (getActiveChar().getHomeX() == 0) getActiveChar().getHomeLocation();

        // Check if siege is in progress
        if (getActiveChar().getCastle() != null && getActiveChar().getCastle().getSiege().getIsInProgress())
        {
            L2PcInstance player = null;
            if (object instanceof L2PcInstance)
                player = (L2PcInstance) object;
            else if (object instanceof L2Summon)
                player = ((L2Summon)object).getOwner();

            // Check if player is not the defender
            if (player != null && (player.getClan() == null || getActiveChar().getCastle().getSiege().getAttackerClan(player.getClan()) != null))
            {
                //if (Config.DEBUG) _log.fine(getObjectId()+": PK "+player.getObjectId()+" entered scan range");
                if (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
                    getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);//(L2Character)object);
            }
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.