Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.L2Object


    // if the player is in a party, gather a list of all matching party members (possibly
    // including this player)
    FastList<L2PcInstance> candidates = new FastList<L2PcInstance>();

    // get the target for enforcing distance limitations.
    L2Object target = player.getTarget();
    if(target == null)
    {
      target = player;
    }
View Full Code Here


    // if the player is in a party, gather a list of all matching party members (possibly
    // including this player)
    FastList<L2PcInstance> candidates = new FastList<L2PcInstance>();

    // get the target for enforcing distance limitations.
    L2Object target = player.getTarget();
    if(target == null)
    {
      target = player;
    }
View Full Code Here

    return ADMIN_COMMANDS;
  }

  private void addExpSp(L2PcInstance activeChar)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
View Full Code Here

    target = null;
  }

  private boolean adminAddExpSp(L2PcInstance activeChar, String ExpSp)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
View Full Code Here

    return true;
  }

  private boolean adminRemoveExpSP(L2PcInstance activeChar, String ExpSp)
  {
    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;

    if(target instanceof L2PcInstance)
    {
      player = (L2PcInstance) target;
View Full Code Here

    else if(command.startsWith("admin_npc_say"))
    {
      try
      {
        L2Object target = activeChar.getTarget();

        if(activeChar.getSayMode() != null)
        {
          activeChar.setSayMode(null);
          activeChar.sendMessage("NpcSay mode off");
        }
        else
        {
          if(target != null && target instanceof L2NpcInstance)
          {
            activeChar.setSayMode(target);
            activeChar.sendMessage("NpcSay mode on for " + target.getName());
          }
          else
          {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));

            return false;
          }
        }

        target = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
       
        activeChar.sendMessage("Target Npc before. Use: //npc_say");
      }
    }

    else if(command.equals("admin_play_sounds"))
    {
      AdminHelpPage.showHelpPage(activeChar, "songs/songs.htm");
    }
    else if(command.startsWith("admin_play_sounds"))
    {
      try
      {
        AdminHelpPage.showHelpPage(activeChar, "songs/songs" + command.substring(17) + ".htm");
      }
      catch(StringIndexOutOfBoundsException e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace()
      }
    }
    else if(command.startsWith("admin_play_sound"))
    {
      try
      {
        playAdminSound(activeChar, command.substring(17));
      }
      catch(StringIndexOutOfBoundsException e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace()
      }
    }
   
    else if (command.equals("admin_para")||command.equals("admin_para_menu"))
    {
    String type = "1";
       try
       {
       type = st.nextToken();
       }
       catch(Exception e){}
            try
             {
             L2Object target = activeChar.getTarget();
             L2Character player = null;
             if (target instanceof L2Character)
               {
                player = (L2Character)target;
                if (type.equals("1"))
                    player.startAbnormalEffect(0x0400);
                else
                    player.startAbnormalEffect(0x0800);
                player.setIsParalyzed(true);
                StopMove sm = new StopMove(player);
                player.sendPacket(sm);
               player.broadcastPacket(sm);
               }
             }
       catch (Exception e)
       {}
    }
   
    else if (command.equals("admin_unpara")||command.equals("admin_unpara_menu"))
    {
    try
    {
      L2Object target = activeChar.getTarget();
      L2Character player = null;
      if (target instanceof L2Character)
      {
         player = (L2Character)target;
         player.stopAbnormalEffect((short)0x0400);
         player.setIsParalyzed(false);
      }
    }
    catch (Exception e)
    {}
    }
   
    else if (command.startsWith("admin_para_all"))
    {
    try
    {
    for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
      {
      if (!player.isGM())
         {
           player.startAbnormalEffect(0x0400);
           player.setIsParalyzed(true);
          StopMove sm = new StopMove(player);
           player.sendPacket(sm);
           player.broadcastPacket(sm);
           }
      }
    }
    catch (Exception e)
    { }
    }
   
    else if (command.startsWith("admin_unpara_all"))
    {
    try
    {
    for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
      {
         player.stopAbnormalEffect(0x0400);
         player.setIsParalyzed(false);
      }
    }
    catch (Exception e)
    {}
    }

    else if(command.startsWith("admin_bighead"))
    {
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;

        if(target instanceof L2Character)
        {
          player = (L2Character) target;
          player.startAbnormalEffect(0x2000);
        }

        target = null;
        player = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    else if(command.startsWith("admin_shrinkhead"))
    {
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;

        if(target instanceof L2Character)
        {
          player = (L2Character) target;
          player.stopAbnormalEffect((short) 0x2000);
        }

        target = null;
        player = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    else if(command.startsWith("admin_gmspeed"))
    {
      try
      {
        int val = Integer.parseInt(st.nextToken());
        boolean sendMessage = activeChar.getFirstEffect(7029) != null;

        activeChar.stopSkillEffects(7029);

        if(val == 0 && sendMessage)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED).addSkillName(7029));
        }
        else if(val >= 1 && val <= 4)
        {
          L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
          activeChar.doCast(gmSpeedSkill);
        }
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
        e.printStackTrace();
     
        activeChar.sendMessage("Use //gmspeed value (0=off...4=max).");
      }
      finally
      {
        activeChar.updateEffectIcons();
      }
    }

    else if(command.startsWith("admin_polyself"))
    {
      try
      {
        String id = st.nextToken();

        activeChar.getPoly().setPolyInfo("npc", id);
        activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);

        CharInfo info1 = new CharInfo(activeChar);
        activeChar.broadcastPacket(info1);
        UserInfo info2 = new UserInfo(activeChar);
        activeChar.sendPacket(info2);

        info1 = null;
        info2 = null;
        id = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    else if(command.startsWith("admin_unpolyself"))
    {
      try
      {
        activeChar.getPoly().setPolyInfo(null, "1");
        activeChar.decayMe();
        activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());

        CharInfo info1 = new CharInfo(activeChar);
        activeChar.broadcastPacket(info1);
        UserInfo info2 = new UserInfo(activeChar);
        activeChar.sendPacket(info2);

        info1 = null;
        info2 = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    else if(command.equals("admin_clear_teams"))
    {
      try
      {
        for(L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
        {
          player.setTeam(0);
          player.broadcastUserInfo();
        }
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    else if(command.startsWith("admin_setteam_close"))
    {
      try
      {
        String val = st.nextToken();

        int teamVal = Integer.parseInt(val);

        for(L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
        {
          if(activeChar.isInsideRadius(player, 400, false, true))
          {
            player.setTeam(0);

            if(teamVal != 0)
            {
              SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
              sm.addString("You have joined team " + teamVal);
              player.sendPacket(sm);
              sm = null;
            }

            player.broadcastUserInfo();
          }
        }

        val = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    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);
        sm = null;
      }

      player.broadcastUserInfo();

      val = null;
      target = null;
      player = null;
    }

    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)
              {
                if(Config.ENABLE_ALL_EXCEPTIONS)
                  nbe.printStackTrace();
               
                activeChar.sendMessage("Incorrect parameter");
              }
            }

            player = null;
          }
        }
        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]");
        }

        target = null;
        obj = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }

    else if(command.startsWith("debuff"))
    {
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;

        if(target instanceof L2Character)
        {
          player = (L2Character) target;
          player.stopAllEffects();
          activeChar.sendMessage("Effects has been cleared from " + player + ".");
        }

        target = null;
        player = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          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
            {
              try
              {
                int radius = Integer.parseInt(target);

                for(L2Object object : activeChar.getKnownList().getKnownObjects().values())
                  if(activeChar.isInsideRadius(object, radius, false, false))
                  {
                    performAbnormal(abnormal, object);
                  }

                activeChar.sendMessage(radius + " units radius affected by your request.");
              }
              catch(NumberFormatException nbe)
              {
                if(Config.ENABLE_ALL_EXCEPTIONS)
                  nbe.printStackTrace();
               
                activeChar.sendMessage("Usage: //abnormal <hex_abnormal_mask> [player|radius]");
              }
            }

            player = null;
          }

          parm = null;
        }
        else if(st.countTokens() == 1)
        {
          int abnormal = Integer.decode("0x" + st.nextToken());

          if(obj == null)
          {
            obj = activeChar;
          }
         
          if(performAbnormal(abnormal, obj))
          {
            activeChar.sendMessage(obj.getName() + "'s abnormal status was affected by your request.");
          }
          else
          {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
          }
        }
        else if(!command.contains("menu"))
        {
          activeChar.sendMessage("Usage: //abnormal <abnormal_mask> [player_name|radius]");
        }

        target = null;
        obj = null;
      }
      catch(Exception e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
      }
    }
     else if(command.startsWith("admin_adminspeed"))
    {
                try
                {
                  int val = Integer.parseInt(st.nextToken());
                 boolean sendMessage = activeChar.getFirstEffect(10000) != null;
                
                         activeChar.stopSkillEffects(10000);
                
                         if(val == 0 && sendMessage)
                         {
                           activeChar.sendPacket(new SystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED).addSkillName(10000));
                         }
                         else if(val >= 1 && val <= 4)
                         {
                           L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(10000, val);
                           activeChar.doCast(gmSpeedSkill);
                         }
                       }
                       catch(Exception e)
                       {
                         if(Config.ENABLE_ALL_EXCEPTIONS)
                         e.printStackTrace();
                      
                         activeChar.sendMessage("Use //gmspeed value (0=off...4=max).");
                       }
                       finally
                {
                     activeChar.updateEffectIcons();
                    }             
            }

    else if(command.startsWith("admin_effect"))
    {
      try
      {
        L2Object obj = activeChar.getTarget();

        int level = 1, hittime = 1;
        int skill = Integer.parseInt(st.nextToken());

        if(st.hasMoreTokens())
        {
          level = Integer.parseInt(st.nextToken());
        }

        if(st.hasMoreTokens())
        {
          hittime = Integer.parseInt(st.nextToken());
        }

        if(obj == null)
        {
          obj = activeChar;
        }
       
        if(!(obj instanceof L2Character))
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
        }
        else
        {
          L2Character target = (L2Character) obj;

          target.broadcastPacket(new MagicSkillUser(target, activeChar, skill, level, hittime, 0));
          activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");

        }
      }
      catch(Exception e)
      {
View Full Code Here

        activeChar.sendMessage("Usage: //del_drop <npc_id> <item_id> <category>");
      }
    }
    else if(command.startsWith("admin_box_access"))
    {
      L2Object target = activeChar.getTarget();
      String[] players = command.split(" ");

      if(target instanceof L2BoxInstance)
      {
        L2BoxInstance box = (L2BoxInstance) target;
View Full Code Here

                {
                  _log.severe("Couldn't find skill handler for HEAL.");
                  continue;
                }

                L2Object tgts[] = new L2Object[] { target };
                try
                {
                  Healhandler.useSkill(activeChar, skill, tgts);
                }
                catch(IOException e)
View Full Code Here

    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(ActionFailed.STATIC_PACKET);
View Full Code Here

              {
                _actor.setTarget(_actor);
              }
            }

            L2Object OldTarget = _actor.getTarget();

            clientStopMoving(null);
            _accessor.doCast(sk);
            _actor.setTarget(OldTarget);

            OldTarget = null;

            return;
          }
        }
      }

      // Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
      if(!_actor.isAttackingNow() && _actor.getRunSpeed() == 0 && _actor.getKnownList().knowsObject(attackTarget))
      {
        // Cancel the target
        _actor.getKnownList().removeKnownObject(attackTarget);
        _actor.setTarget(null);
        setIntention(AI_INTENTION_IDLE, null, null);
      }
      else
      {
        double dx = _actor.getX() - attackTarget.getX();
        double dy = _actor.getY() - attackTarget.getY();
        double dz = _actor.getZ() - attackTarget.getZ();
        double homeX = attackTarget.getX() - sGuard.getHomeX();
        double homeY = attackTarget.getY() - sGuard.getHomeY();

        // Check if the L2SiegeGuardInstance isn't too far from it's home location
        if(dx * dx + dy * dy > 10000 && homeX * homeX + homeY * homeY > 3240000 && _actor.getKnownList().knowsObject(attackTarget))
        {
          // Cancel the target
          _actor.getKnownList().removeKnownObject(attackTarget);
          _actor.setTarget(null);
          setIntention(AI_INTENTION_IDLE, null, null);
        }
        else
        // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
        {
          // Temporary hack for preventing guards jumping off towers,
          // before replacing this with effective geodata checks and AI modification
          if(dz * dz < 170 * 170)
          {
            moveToPawn(attackTarget, range);
          }
        }
      }

      return;

    }
    // Else, if the actor is muted and far from target, just "move to pawn"
    else if(_actor.isMuted() && dist_2 > (range + 20) * (range + 20))
    {
      // Temporary hack for preventing guards jumping off towers,
      // before replacing this with effective geodata checks and AI modification
      double dz = _actor.getZ() - attackTarget.getZ();

      // normally 130 if guard z coordinates correct
      if(dz * dz < 170 * 170)
      {
        moveToPawn(attackTarget, range);
      }

      return;
    }
    // Else, if this is close enough to attack
    else if(dist_2 <= (range + 20) * (range + 20))
    {
      // Force mobs to attak anybody if confused
      L2Character hated = null;

      if(_actor.isConfused())
      {
        hated = attackTarget;
      }
      else
      {
        hated = ((L2Attackable) _actor).getMostHated();
      }

      if(hated == null)
      {
        setIntention(AI_INTENTION_ACTIVE, null, null);
        return;
      }

      if(hated != attackTarget)
      {
        setAttackTarget(hated);
      }

      _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

      // check for close combat skills && heal/buff skills
      if(!_actor.isMuted() && Rnd.nextInt(100) <= 5)
      {
        for(L2Skill sk : skills)
        {
          int castRange = sk.getCastRange();

          if(castRange * castRange >= dist_2 && castRange <= 70 && !sk.isPassive() && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !_actor.isSkillDisabled(sk.getId()))
          {
            if(sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL)
            {
              boolean useSkillSelf = true;

              if(sk.getSkillType() == L2Skill.SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
              {
                useSkillSelf = false;
                break;
              }

              if(sk.getSkillType() == L2Skill.SkillType.BUFF)
              {
                L2Effect[] effects = _actor.getAllEffects();

                for(int i = 0; effects != null && i < effects.length; i++)
                {
                  L2Effect effect = effects[i];

                  if(effect.getSkill() == sk)
                  {
                    useSkillSelf = false;
                    break;
                  }
                }
              }
              if(useSkillSelf)
              {
                _actor.setTarget(_actor);
              }
            }

            L2Object OldTarget = _actor.getTarget();

            clientStopMoving(null);
            _accessor.doCast(sk);
            _actor.setTarget(OldTarget);

View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.L2Object

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.