Package com.l2jfrozen.gameserver.model.actor.instance

Examples of com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance


    else if(event.equalsIgnoreCase("check_ai"))
    {
      cancelQuestTimer("check_ai", null, null);
      if(!_isSpawned)
      {
        L2NpcInstance gordon_ai = findTemplate(GORDON);
        if(gordon_ai != null)
        {
          _isSpawned = true;
          startQuestTimer("Start", 1000, gordon_ai, null,true);
          return super.onAdvEvent(event, npc, player);
View Full Code Here


    return super.onKill(npc, killer, isPet);
  }

  public L2NpcInstance findTemplate(int npcId)
  {
    L2NpcInstance npc = null;
    for(L2Spawn spawn : SpawnTable.getInstance().getSpawnTable().values())
    {
      if(spawn != null && spawn.getNpcid() == npcId)
      {
        npc = spawn.getLastSpawn();
View Full Code Here

      if(!(cha instanceof L2NpcInstance))
      {
        continue;
      }

      L2NpcInstance npc = (L2NpcInstance) cha;

      String faction_id = ((L2NpcInstance) actor).getFactionId();

      if(!faction_id.equalsIgnoreCase(npc.getFactionId()))
      {
        continue;
      }

      faction_id = null;

      // Check if the L2Object is inside the Faction Range of the actor
      if(npc.getAI() !=null && (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE
          || npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
          && actor.isInsideRadius(npc, npc.getFactionRange(), false, true)
          && target.isInsideRadius(npc, npc.getFactionRange(), false, true))
      {
        if(Config.GEODATA > 0)
        {
          if(GeoData.getInstance().canSeeTarget(npc, target))
          {
            // Notify the L2Object AI with EVT_AGGRESSION
            L2CharacterAI ai = npc.getAI();
            if(ai!=null)
              ai.notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
          }
        }
        else
        {
          if(!npc.isDead() && Math.abs(target.getZ() - npc.getZ()) < 600)
          {
            // Notify the L2Object AI with EVT_AGGRESSION
            L2CharacterAI ai = npc.getAI();
            if(ai!=null)
              ai.notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
          }
        }
      }
View Full Code Here

      L2Spawn spawn = new L2Spawn(template1);
      spawn.setId(IdFactory.getInstance().getNextId());
      spawn.setLocx(target.getX());
      spawn.setLocy(target.getY());
      spawn.setLocz(target.getZ());
      L2NpcInstance result = spawn.spawnOne();

      activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);

      SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
      activeChar.sendPacket(sm);
View Full Code Here

         
          RegionBBSManager.getInstance().changeCommunityBoard();
        }
        else if (target instanceof L2NpcInstance)
        {
          L2NpcInstance npc = (L2NpcInstance) target;
          oldName = npc.getName();
          npc.setName(val);
          npc.updateAbnormalEffect();
        }
       
        if (oldName == null)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
          return false;
        }
        activeChar.sendMessage("Name changed from " + oldName + " to " + val);
        return true;
      } // changes char name
      case admin_edit_character:
      {
        editCharacter(activeChar);
        return true;
      }
      case admin_current_player:
      {
        showCharacterInfo(activeChar, null);
        return true;
      }
      case admin_nokarma:
      {
        setTargetKarma(activeChar, 0);
        return true;
      }
      case admin_setkarma:
      {
       
        int karma = 0;
       
        if (st.hasMoreTokens())
        {
          String val = st.nextToken();
         
          try
          {
            karma = Integer.parseInt(val);
            val = null;
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Usage: //setkarma new_karma_for_target(number)");
            return false;
          }
        }
        else
        {
          activeChar.sendMessage("Usage: //setkarma new_karma_for_target");
          return false;
        }
       
        setTargetKarma(activeChar, karma);
        return true;
       
      }
      case admin_character_list:
      case admin_character_info:
      {   
        String val = "";
       
        if (st.hasMoreTokens())
        {     
          while (st.hasMoreTokens())
          {
            if (val.equals(""))
            {
              val = st.nextToken();
            }
            else
            {
              val += " " + st.nextToken();
            }
          }     
        }
        else
        {
          activeChar.sendMessage("Usage: //character_info <player_name>");
          return false;
        }
       
        L2PcInstance target = L2World.getInstance().getPlayer(val);
       
        if (target != null)
        {
          showCharacterInfo(activeChar, target);
          val = null;
          return true;
        }
        activeChar.sendPacket(new SystemMessage(SystemMessageId.CHARACTER_DOES_NOT_EXIST));
        val = null;
        return false;
      } // given a player name:{} displays an information window
      case admin_show_characters:
      {     
        String val = "";
       
        if (st.hasMoreTokens())
        {
          val = st.nextToken();
         
          try
          {
            int page = Integer.parseInt(val);
            listCharacters(activeChar, page);
            val = null;
            return true;
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Usage: //show_characters <page_number>");
            val = null;
            listCharacters(activeChar, 0);
            return false;
          }       
        }
        activeChar.sendMessage("Usage: //show_characters <page_number>");
        listCharacters(activeChar, 0);
        return false;
      }
      case admin_find_character:
      {     
        String val = "";
       
        if (st.hasMoreTokens())
        {
         
          while (st.hasMoreTokens())
          {
            if (val.equals(""))
            {
              val = st.nextToken();
            }
            else
            {
              val += " " + st.nextToken();
            }
          }     
        }
        else
        {
          activeChar.sendMessage("Usage: //find_character <player_name>");
          listCharacters(activeChar, 0);
          return false;
        }
       
        findCharacter(activeChar, val);
        val = null;
        return true;
      }
      case admin_find_dualbox:
      {     
        String val = "";
        int boxes = 2;
       
        if (st.hasMoreTokens())
        {
          val = st.nextToken();
         
          try
          {
            boxes = Integer.parseInt(val);
            val = null;
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Usage: //find_dualbox <boxes_number>(default 2)");
            val = null;
            listCharacters(activeChar, 0);
            return false;
          }       
        }
       
        findMultibox(activeChar, boxes);
        return true;     
      }
      case admin_find_ip:
      {       
        String val = "";
       
        if (st.hasMoreTokens())
        {
          val = st.nextToken();       
        }
        else
        {
          activeChar.sendMessage("Usage: //find_ip <ip>");
          listCharacters(activeChar, 0);
          return false;
        }
       
        try
        {
          findCharactersPerIp(activeChar, val);
         
        }
        catch (IllegalArgumentException e)
        {
          activeChar.sendMessage("Usage: //find_ip <ip>");
          listCharacters(activeChar, 0);
          return false;
        }
        return true;
      } // find all the player connections from a given IPv4 number
      case admin_find_account:
      {     
        String val = "";
       
        if (st.hasMoreTokens())
        {
          val = st.nextToken();     
        }
        else
        {
          activeChar.sendMessage("Usage: //find_account <account_name>");
          listCharacters(activeChar, 0);
          return false;
        }
       
        findCharactersPerAccount(activeChar, val);
        return true;
       
      } // list all the characters from an account (useful for GMs w/o DB access)
      case admin_save_modifications:
      {   
        String val = "";
       
        if (st.hasMoreTokens())
        {     
          while (st.hasMoreTokens())
          {
           
            if (val.equals(""))
              val = st.nextToken();
            else
              val = val + " " + st.nextToken();       
          }   
        }
        else
        {
          activeChar.sendMessage("Usage: //save_modifications <mods>");
          listCharacters(activeChar, 0);
          return false;
        }
       
        adminModifyCharacter(activeChar, val);
        val = null;
        return true;
       
      } // consider it deprecated...
      case admin_rec:
      {   
        String val = "";
        int value = 1;
       
        if (st.hasMoreTokens())
        {
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Usage: //rec <value>(default 1)");
            return false;
          }     
        }
        else
        {
          activeChar.sendMessage("Usage: //rec <value>(default 1)");
          return false;
        }
       
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
       
        if (target instanceof L2PcInstance)
        {
          player = (L2PcInstance) target;
        }
        else
        {
          activeChar.sendMessage("Select player before. Usage: //rec <value>(default 1)");
          listCharacters(activeChar, 0);
          return false;
        }
        target = null;
       
        player.setRecomHave(player.getRecomHave() + value);
        SystemMessage sm = new SystemMessage(SystemMessageId.GM_S1);
        sm.addString("You have been recommended by a GM");
        player.sendPacket(sm);
        player.broadcastUserInfo();
        player = null;
        sm = null;
        val = null;
       
        return true;       
      }
      case admin_setclass:
      {     
        String val = "";
        int classidval = 0;
       
        if (st.hasMoreTokens())
        {
          val = st.nextToken();
         
          try
          {
            classidval = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Usage: //setclass <value>(default 1)");
            return false;
          }         
        }
        else
        {
          AdminHelpPage.showSubMenuPage(activeChar, "charclasses.htm");
          return false;
        }
       
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
       
        if (target instanceof L2PcInstance)
        {
          player = (L2PcInstance) target;
        }
        else
          return false;
       
        boolean valid = false;
       
        for (ClassId classid : ClassId.values())
          if (classidval == classid.getId())
          {
            valid = true;
          }
       
        if (valid && player.getClassId().getId() != classidval)
        {
          player.setClassId(classidval);
         
          ClassId classId = ClassId.getClassIdByOrdinal(classidval);
         
          if (!player.isSubClassActive())
          {
            // while(classId.level() != 0){ //go to root
            // classId = classId.getParent();
            // }
           
            player.setBaseClass(classId);
          }
         
          String newclass = player.getTemplate().className;
          player.store();
         
          if (player != activeChar)
          {
            player.sendMessage("A GM changed your class to " + newclass);
          }
         
          player.broadcastUserInfo();
          activeChar.sendMessage(player.getName() + " changed to " + newclass);
         
          newclass = null;
          return true;
        }
        activeChar.sendMessage("Usage: //setclass <valid_new_classid>");
        return false;
      }
      case admin_settitle:
      {     
        String val = "";
       
        if (st.hasMoreTokens())
        {   
          while (st.hasMoreTokens())
          {
            if (val.equals(""))
            {
              val = st.nextToken();
            }
            else
            {
              val += " " + st.nextToken();
            }
          }       
        }
        else
        {
          activeChar.sendMessage("Usage: //settitle <new_title>");
          return false;
        }
       
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        L2NpcInstance npc = null;
       
        if (target == null)
        {
          player = activeChar;
        }
        else if (target instanceof L2PcInstance)
        {
          player = (L2PcInstance) target;
        }
        else if (target instanceof L2NpcInstance)
        {
          npc = (L2NpcInstance) target;
        }
        else
        {
          activeChar.sendMessage("Select your target before the command");
          return false;
        }
       
        target = null;
        st = null;
       
        if (player != null)
        {
          player.setTitle(val);
          if (player != activeChar)
          {
            player.sendMessage("Your title has been changed by a GM");
          }
          player.broadcastTitleInfo();
        }
        else if (npc != null)
        {
          npc.setTitle(val);
          npc.updateAbnormalEffect();
        }
       
        val = null;
       
        return true;
View Full Code Here

       
        final int hp = info.getInteger("currentHP");
        final int mp = info.getInteger("currentMP");
        L2GrandBossInstance valakas = (L2GrandBossInstance) addSpawn(VALAKAS, loc_x, loc_y, loc_z, heading, false, 0);
        GrandBossManager.getInstance().addBoss(valakas);
        final L2NpcInstance _valakas = valakas;
       
        ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
        {
          @Override
          public void run()
          {
            try
            {
              _valakas.setCurrentHpMp(hp, mp);
              _valakas.setRunning();
            }
            catch (Throwable e)
            {}
          }
        }, 100L);
View Full Code Here

       
        L2GrandBossInstance valakas = (L2GrandBossInstance) addSpawn(VALAKAS, loc_x, loc_y, loc_z, heading, false, 0);
        GrandBossManager.getInstance().addBoss(valakas);
       
        lastAttackTime = System.currentTimeMillis();
        final L2NpcInstance _valakas = valakas;
        ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
        {
          @Override
          public void run()
          {
View Full Code Here

    setAmount(1);
  }

  public L2NpcInstance doGroupSpawn()
  {
    L2NpcInstance mob = null;

    try
    {
      if(_template.type.equalsIgnoreCase("L2Pet") || _template.type.equalsIgnoreCase("L2Minion"))
        return null;

      Object[] parameters =
      {
          IdFactory.getInstance().getNextId(), _template
      };
      Object tmp = _constructor.newInstance(parameters);

      if(!(tmp instanceof L2NpcInstance))
        return null;

      mob = (L2NpcInstance) tmp;

      int newlocx, newlocy, newlocz;

      if(getLocx() == 0 && getLocy() == 0)
      {
        if(getLocation() == 0)
          return null;

        int p[] = TerritoryTable.getInstance().getRandomPoint(getLocation());
        newlocx = p[0];
        newlocy = p[1];
        newlocz = p[2];
      }
      else
      {
        newlocx = getLocx();
        newlocy = getLocy();
        newlocz = getLocz();
      }

      mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());

      if(getHeading() == -1)
      {
        mob.setHeading(Rnd.nextInt(61794));
      }
      else
      {
        mob.setHeading(getHeading());
      }

      mob.setSpawn(this);
      mob.spawnMe(newlocx, newlocy, newlocz);
      mob.onSpawn();

      if(Config.DEBUG)
      {
        _log.finest("spawned Mob ID: " + _template.npcId + " ,at: " + mob.getX() + " x, " + mob.getY() + " y, " + mob.getZ() + " z");
      }

      parameters = null;
      tmp = null;
View Full Code Here

      spawn.setLocx(x);
      spawn.setLocy(y);
      spawn.setLocz(z);

      L2NpcInstance tree = spawn.spawnOne();
      L2World.getInstance().storeObject(tree);
      objectQueue.add(tree);

      spawn = null;
      tree = null;
View Full Code Here

          if(!(obj instanceof L2NpcInstance))
          {
            continue;
          }

          L2NpcInstance npc = (L2NpcInstance) obj;
          String faction_id = ((L2NpcInstance) _actor).getFactionId();

          if(!faction_id.equalsIgnoreCase(npc.getFactionId()))
          {
            continue;
          }

          faction_id = null;

          if(_actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200)
          {
            npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
          }
          npc = null;
        }
      }
     
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance

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.