Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.L2Object


     * @param id
     */
    private void adminTestSkill(L2PcInstance activeChar, int id)
    {
        L2Character player;
        L2Object target = activeChar.getTarget();
        if(target == null || !(target instanceof L2Character))
        {
            player = activeChar;
        }
        else
View Full Code Here


  {
    if (!Config.ALT_PRIVILEGES_ADMIN)
      if (!activeChar.isGM() || activeChar.getAccessLevel() < Config.GM_ACCESSLEVEL || activeChar.getTarget() == null || !(activeChar.getTarget() instanceof L2PcInstance))
        return false;

    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;
    if (target instanceof L2PcInstance)
      player = (L2PcInstance)target;
    else
    {
View Full Code Here

    GMAudit.auditGMAction(adminInstance.getName(), command, (adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target"), "");

    if (command.equals("admin_tvt_add"))
    {
      L2Object target = adminInstance.getTarget();

      if (target == null || !(target instanceof L2PcInstance))
      {
        adminInstance.sendMessage("You should select a player!");
        return true;
      }

      add(adminInstance, (L2PcInstance)target);
    }
    else if (command.equals("admin_tvt_remove"))
    {
      L2Object target = adminInstance.getTarget();

      if (target == null || !(target instanceof L2PcInstance))
      {
        adminInstance.sendMessage("You should select a player!");
        return true;
View Full Code Here

    {
      sendPacket(new ActionFailed());
      return;
    }

    L2Object target = player.getTarget();

    if (!(target instanceof L2ManorManagerInstance))
      target = player.getLastFolkNPC();

    if (!(target instanceof L2ManorManagerInstance))
View Full Code Here

    L2PcInstance activeChar = getClient().getActiveChar();

    if (activeChar == null)
      return;

    L2Object obj;

    if (activeChar.getTargetId() == _objectId)
      obj = activeChar.getTarget();
    else
      obj = L2World.getInstance().findObject(_objectId);

    // If object requested does not exist, add warn msg into logs
    if (obj == null)
    {
      // pressing e.g. pickup many times quickly would get you here
      // _log.warning("Character: " + activeChar.getName() + " request action with non existent ObjectID:" + _objectId);
      getClient().sendPacket(new ActionFailed());
      return;
    }

    // Check if the target is valid, if the player haven't a shop or isn't the requester of a transaction (ex : FriendInvite, JoinAlly, JoinParty...)
    if (activeChar.getPrivateStoreType()==0 && activeChar.getActiveRequester()==null)
    {
      switch (_actionId)
      {
        case 0:
          obj.onAction(activeChar);
          break;
        case 1:
          if (obj instanceof L2Character && ((L2Character)obj).isAlikeDead())
            obj.onAction(activeChar);
          else
            obj.onActionShift(getClient());
          break;
        default:
          // Ivalid action detected (probably client cheating), log this
          _log.warning("Character: " + activeChar.getName() + " requested invalid action: " + _actionId);
          getClient().sendPacket(new ActionFailed());
View Full Code Here

        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 (!player.isGM() && (target == null                // No target (ie GM Shop)
            || !(target instanceof L2MerchantInstance || target instanceof L2MercManagerInstance// Target not a merchant and not mercmanager
          || !player.isInsideRadius(target, L2NpcInstance.INTERACTION_DISTANCE, false, false)   // Distance is too far
              )) return;
View Full Code Here

        player = st.nextToken();
        plyr = L2World.getInstance().getPlayer(player);
      }
      catch(Exception e)
      {
        L2Object target = activeChar.getTarget();
        if (target!=null && target instanceof L2PcInstance)
          plyr = (L2PcInstance)target;
        else
          activeChar.sendMessage("Usage: //ban [account_name] (if none, target char's account gets banned)");
      }
View Full Code Here

        GMAudit.auditGMAction(activeChar.getName(), command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"), "");

    if (command.equals("admin_invul")) handleInvul(activeChar);
        if (command.equals("admin_setinvul")){
           L2Object target = activeChar.getTarget();
            if (target instanceof L2PcInstance){
              handleInvul((L2PcInstance)target);
            }
        }
    return true;
View Full Code Here

      getClient().sendPacket(new ActionFailed());
      return;
    }

    L2Summon pet = activeChar.getPet();
    L2Object target = activeChar.getTarget();

    if (Config.DEBUG)
      _log.info("Requested Action ID: " + String.valueOf(_actionId));

    switch (_actionId)
    {
    case 0:
      if (activeChar.getMountType() != 0)
        break;

      if (target != null
          && !activeChar.isSitting()
          && target instanceof L2StaticObjectInstance
          && ((L2StaticObjectInstance)target).getType() == 1
          && CastleManager.getInstance().getCastle(target) != null
          && activeChar.isInsideRadius(target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false)
      )
      {
        ChairSit cs = new ChairSit(activeChar,((L2StaticObjectInstance)target).getStaticObjectId());
        activeChar.sendPacket(cs);
        activeChar.sitDown();
        activeChar.broadcastPacket(cs);
        break;
      }

      if (activeChar.isSitting())
        activeChar.standUp();
      else
        activeChar.sitDown();

      if (Config.DEBUG)
        _log.fine("new wait type: "+(activeChar.isSitting() ? "SITTING" : "STANDING"));

      break;
    case 1:
      if (activeChar.isRunning())
        activeChar.setWalking();
      else
        activeChar.setRunning();

      if (Config.DEBUG)
        _log.fine("new move type: "+(activeChar.isRunning() ? "RUNNING" : "WALKIN"));
      break;
    case 15:
    case 21: // pet follow/stop
      if (pet != null && !pet.isMovementDisabled() && !activeChar.isBetrayed())
        pet.setFollowStatus(!pet.getFollowStatus());

      break;
    case 16:
    case 22: // pet attack
      if (target != null && pet != null && pet != target && !pet.isAttackingDisabled() && !activeChar.isBetrayed())
      {
        if (activeChar.isInOlympiadMode() && !activeChar.isOlympiadStart()){
          // if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
          activeChar.sendPacket(new ActionFailed());
          return;
        }

        if (activeChar.getAccessLevel() < Config.GM_PEACEATTACK &&
            activeChar.isInsidePeaceZone(pet, target))
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
          return;
        }

        if (target.isAutoAttackable(activeChar) || _ctrlPressed)
        {
          if (target instanceof L2DoorInstance)
          {
            if(((L2DoorInstance)target).isAttackable(activeChar) && pet.getNpcId() != L2SiegeSummonInstance.SWOOP_CANNON_ID)
              pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
          }
          // siege golem AI doesn't support attacking other than doors at the moment
          else if (pet.getNpcId() != L2SiegeSummonInstance.SIEGE_GOLEM_ID)
            pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
        }
      }
      break;
    case 17:
    case 23: // pet - cancel action
      if (pet != null && !pet.isMovementDisabled() && !activeChar.isBetrayed())
        pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);

      break;
    case 19: // pet unsummon
      if (pet != null && !activeChar.isBetrayed())
      {
        //returns pet to control item
        if (pet.isDead())
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.DEAD_PET_CANNOT_BE_RETURNED));
        }
        else if (pet.isAttackingNow() || pet.isRooted())
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.PET_CANNOT_SENT_BACK_DURING_BATTLE));
        }
        else
        {
          // if it is a pet and not a summon
          if (pet instanceof L2PetInstance)
          {
            L2PetInstance petInst = (L2PetInstance)pet;

            // if the pet is more than 40% fed
            if (petInst.getCurrentFed() > (petInst.getMaxFed() * 0.40))
              pet.unSummon(activeChar);
            else
              activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_RESTORE_HUNGRY_PETS));
          }
        }
      }
      break;
    case 38: // pet mount
      // mount
      if (pet != null && pet.isMountable() && !activeChar.isMounted() && !activeChar.isBetrayed())
      {
        if (activeChar.isDead())
        {
          //A strider cannot be ridden when dead
          SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_DEAD);
          activeChar.sendPacket(msg);
          msg = null;
        }
        else if (pet.isDead())
        {
          //A dead strider cannot be ridden.
          SystemMessage msg = new SystemMessage(SystemMessageId.DEAD_STRIDER_CANT_BE_RIDDEN);
          activeChar.sendPacket(msg);
          msg = null;
        }
        else if (pet.isInCombat() || pet.isRooted())
        {
          //A strider in battle cannot be ridden
          SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_IN_BATLLE_CANT_BE_RIDDEN);
          activeChar.sendPacket(msg);
          msg = null;
        }
        else if (activeChar.isInCombat())
        {
          //A strider cannot be ridden while in battle
          SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_IN_BATTLE);
          activeChar.sendPacket(msg);
          msg = null;
        }
        else if (activeChar.isSitting() || activeChar.isMoving())
        {
          //A strider can be ridden only when standing
          SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CAN_BE_RIDDEN_ONLY_WHILE_STANDING);
          activeChar.sendPacket(msg);
          msg = null;
        }
        else if (activeChar.isFishing())
        {
          //You can't mount, dismount, break and drop items while fishing
          SystemMessage msg = new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_2);
          activeChar.sendPacket(msg);
          msg = null;
        }
        else if (activeChar.isCursedWeaponEquiped())
        {
          //You can't mount, dismount, break and drop items while weilding a cursed weapon
          SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_IN_BATTLE);
          activeChar.sendPacket(msg);
        }
        else if (!pet.isDead() && !activeChar.isMounted())
        {
          if(!activeChar.disarmWeapons()) return;
          Ride mount = new Ride(activeChar.getObjectId(), Ride.ACTION_MOUNT, pet.getTemplate().npcId);
          activeChar.broadcastPacket(mount);
          activeChar.setMountType(mount.getMountType());
          activeChar.setMountObjectID(pet.getControlItemId());
          pet.unSummon(activeChar);
        }
      }
      else if (activeChar.isRentedPet())
      {
        activeChar.stopRentPet();
      }
      else if (activeChar.isMounted())
      {
        if (activeChar.setMountType(0))
        {
          if (activeChar.isFlying())activeChar.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
          Ride dismount = new Ride(activeChar.getObjectId(), Ride.ACTION_DISMOUNT, 0);
          activeChar.broadcastPacket(dismount);
          activeChar.setMountObjectID(0);
        }
      }
      break;
    case 32: // Wild Hog Cannon - Mode Change
      useSkill(4230);
      break;
    case 36: // Soulless - Toxic Smoke
      useSkill(4259);
      break;
    case 37:
      if (activeChar.isAlikeDead())
      {
        getClient().sendPacket(new ActionFailed());
        return;
      }
      if(activeChar.getPrivateStoreType() != 0){
        activeChar.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
        activeChar.broadcastUserInfo();
          }
      if (activeChar.isSitting())
        activeChar.standUp();

      if (activeChar.getCreateList() == null)
      {
        activeChar.setCreateList(new L2ManufactureList());
      }

      activeChar.sendPacket(new RecipeShopManageList(activeChar, true));
      break;
    case 39: // Soulless - Parasite Burst
    useSkill(4138);
    break;
    case 41: // Wild Hog Cannon - Attack
    useSkill(4230);
    break;
    case 42: // Kai the Cat - Self Damage Shield
    useSkill(4378, activeChar);
    break;
    case 43: // Unicorn Merrow - Hydro Screw
      useSkill(4137);
      break;
    case 44: // Big Boom - Boom Attack
      useSkill(4139);
      break;
    case 45: // Unicorn Boxer - Master Recharge
      useSkill(4025, activeChar);
      break;
    case 46: // Mew the Cat - Mega Storm Strike
      useSkill(4261);
      break;
    case 47: // Silhouette - Steal Blood
      useSkill(4260);
      break;
    case 48: // Mechanic Golem - Mech. Cannon
      useSkill(4068);
      break;
    case 51:
      // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)
      if (activeChar.isAlikeDead())
      {
        getClient().sendPacket(new ActionFailed());
        return;
      }
      if(activeChar.getPrivateStoreType() != 0){
        activeChar.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
        activeChar.broadcastUserInfo();
          }
      if (activeChar.isSitting())
        activeChar.standUp();

      if (activeChar.getCreateList() == null)
        activeChar.setCreateList(new L2ManufactureList());

      activeChar.sendPacket(new RecipeShopManageList(activeChar, false));
      break;
    case 52: // unsummon
      if (pet != null && pet instanceof L2SummonInstance)
        pet.unSummon(activeChar);
      break;
    case 53: // move to target
      if (target != null && pet != null && pet != target && !pet.isMovementDisabled())
      {
        pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,
            new L2CharPosition(target.getX(),target.getY(), target.getZ(), 0 ));
      }
      break;
    case 54: // move to target hatch/strider
      if (target != null && pet != null && pet != target && !pet.isMovementDisabled())
      {
        pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,
            new L2CharPosition(target.getX(),target.getY(), target.getZ(), 0 ));
      }
      break;
    case 96: // Quit Party Command Channel
      _log.info("98 Accessed");
      break;
View Full Code Here

    return (level >= REQUIRED_LEVEL);
  }

  private void spawnMonster(L2PcInstance activeChar, String monsterId, int respawnTime, int mobCount,boolean permanent)
  {
    L2Object target = activeChar.getTarget();
    if (target == null)
      target = activeChar;
    if (target != activeChar && activeChar.getAccessLevel() < REQUIRED_LEVEL2)
      return;

    L2NpcTemplate template1;
    if (monsterId.matches("[0-9]*"))
    {
      //First parameter was an ID number
      int monsterTemplate = Integer.parseInt(monsterId);
      template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
    }
    else
    {
      //First parameter wasn't just numbers so go by name not ID
      monsterId = monsterId.replace('_', ' ');
      template1 = NpcTable.getInstance().getTemplateByName(monsterId);
    }

    try
    {
      L2Spawn spawn = new L2Spawn(template1);
      spawn.setLocx(target.getX());
      spawn.setLocy(target.getY());
      spawn.setLocz(target.getZ());
      spawn.setAmount(mobCount);
      spawn.setHeading(activeChar.getHeading());
      spawn.setRespawnDelay(respawnTime);
      if (RaidBossSpawnManager.getInstance().isDefined(spawn.getNpcid()))
        activeChar.sendMessage("You cannot spawn another instance of " + template1.name + ".");
      else
      {
        if (RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getNpcid()) != null)
          RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template1.getStatsSet().getDouble("baseHpMax"), template1.getStatsSet().getDouble("baseMpMax"), permanent);
        else
          SpawnTable.getInstance().addNewSpawn(spawn, permanent);
        spawn.init();
        if (!permanent)
          spawn.stopRespawn();
        activeChar.sendMessage("Created " + template1.name + " on " + target.getObjectId());
      }
    }
    catch (Exception e)
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_CANT_FOUND));
View Full Code Here

TOP

Related Classes of net.sf.l2j.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.