public GuardiansSpawner(NpcInstance npc, QuestState st, int _count) {
      NpcTemplate template = NpcHolder.getInstance().getTemplate(Soul_of_Tree_Guardian);
      if (template == null) return;
      try {
        _spawn = new SimpleSpawner(template);
      } catch (Exception e) {
        e.printStackTrace();
      }
      for (int i = 0; i < _count; i++) {
        _spawn.setLoc(Location.findPointToStay(npc, 50, 200));
        _spawn.setHeading(Rnd.get(0, 0xFFFF));
        _spawn.setAmount(1);
        _spawn.doSpawn(true);

        agressor = st.getPlayer().getName();
        if (st.getPlayer().getSummonList().getPet() != null)
          agressors_pet = st.getPlayer().getSummonList().getPet().getName();
        if (st.getPlayer().getParty() != null) {
          agressors_party = new ArrayList<String>();
          for (Player _member : st.getPlayer().getParty().getPartyMembers())
            if (!_member.equals(st.getPlayer())) agressors_party.add(_member.getName());
        }
      }
      _spawn.stopRespawn();
      updateAgression();
    }
Пример #2
0
  @Override
  protected void onEvtAttacked(Creature attacker, int damage) {
    super.onEvtAttacked(attacker, damage);
    OrfenInstance actor = getActor();
    if (actor.isCastingNow()) {
      return;
    }

    double distance = actor.getDistance(attacker);

    // if(attacker.isMuted() &&)
    if (distance > 300 && distance < 1000 && _damSkills.length > 0 && Rnd.chance(10)) {
      Functions.npcSay(
          actor, MsgOnRecall[Rnd.get(MsgOnRecall.length - 1)].sprintf(attacker.getName()));
      teleToLocation(attacker, Location.findFrontPosition(actor, attacker, 0, 50));
      Skill r_skill = _damSkills[Rnd.get(_damSkills.length)];
      if (canUseSkill(r_skill, attacker, -1)) {
        addTaskAttack(attacker, r_skill, 1000000);
      }
    } else if (_paralyze.length > 0 && Rnd.chance(20)) {
      Skill r_skill = _paralyze[Rnd.get(_paralyze.length)];
      if (canUseSkill(r_skill, attacker, -1)) {
        addTaskAttack(attacker, r_skill, 1000000);
      }
    }
  }
Пример #3
0
 private void teleportTo(Player activeChar, Player target, String Cords, int ref) {
   try {
     teleportTo(activeChar, target, Location.parseLoc(Cords), ref);
   } catch (IllegalArgumentException e) {
     activeChar.sendMessage("You must define 3 coordinates required to teleport");
     return;
   }
 }
Пример #4
0
 private void startMoveTask() {
   NpcInstance npc = getActor();
   _lastPoint++;
   if (_lastPoint >= _points.length)
     if (!npc.getReflection().isDefault()) {
       ((HeartInfinityDefence) npc.getReflection()).notifyWagonArrived();
       npc.deleteMe();
       return;
     }
   addTaskMove(Location.findPointToStay(_points[_lastPoint], 250, npc.getGeoIndex()), true);
   doTask();
 }
Пример #5
0
  @Override
  protected void onEvtSeeSpell(Skill skill, Creature caster) {
    super.onEvtSeeSpell(skill, caster);
    OrfenInstance actor = getActor();
    if (actor.isCastingNow()) {
      return;
    }

    double distance = actor.getDistance(caster);
    if (_damSkills.length > 0 && skill.getEffectPoint() > 0 && distance < 1000 && Rnd.chance(20)) {
      Functions.npcSay(actor, MsgOnRecall[Rnd.get(MsgOnRecall.length)].sprintf(caster.getName()));
      teleToLocation(caster, Location.findFrontPosition(actor, caster, 0, 50));
      Skill r_skill = _damSkills[Rnd.get(_damSkills.length)];
      if (canUseSkill(r_skill, caster, -1)) {
        addTaskAttack(caster, r_skill, 1000000);
      }
    }
  }
Пример #6
0
  @Override
  protected void onEvtAttacked(Creature attacker, int damage) {
    NpcInstance actor = getActor();

    if (!_attacked) {
      for (int i = 0; i < 4; i++) {
        try {
          SimpleSpawner sp = new SimpleSpawner(NpcHolder.getInstance().getTemplate(18493));
          sp.setLoc(Location.findPointToStay(actor, 150, 250));
          sp.setReflection(actor.getReflection());
          sp.doSpawn(true);
          sp.stopRespawn();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      _attacked = true;
    }
  }
Пример #7
0
  @SuppressWarnings("rawtypes")
  @Override
  public boolean useAdminCommand(
      Enum comm, String[] wordList, String fullString, Player activeChar) {
    Commands command = (Commands) comm;

    if (!activeChar.getPlayerAccess().CanTeleport) return false;

    switch (command) {
      case admin_show_moves:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/teleports.htm"));
        break;
      case admin_show_moves_other:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/tele/other.htm"));
        break;
      case admin_show_teleport:
        showTeleportCharWindow(activeChar);
        break;
      case admin_teleport_to_character:
        teleportToCharacter(activeChar, activeChar.getTarget());
        break;
      case admin_teleport_to:
      case admin_teleportto:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleportto charName");
          return false;
        }
        String chaName = Util.joinStrings(" ", wordList, 1);
        Player cha = GameObjectsStorage.getPlayer(chaName);
        if (cha == null) {
          activeChar.sendMessage("Player '" + chaName + "' not found in world");
          return false;
        }
        teleportToCharacter(activeChar, cha);
        break;
      case admin_move_to:
      case admin_moveto:
      case admin_teleport:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport x y z [ref]");
          return false;
        }
        teleportTo(
            activeChar,
            activeChar,
            Util.joinStrings(" ", wordList, 1, 3),
            ArrayUtils.valid(wordList, 4) != null && !ArrayUtils.valid(wordList, 4).isEmpty()
                ? Integer.parseInt(wordList[4])
                : 0);
        break;
      case admin_walk:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        try {
          activeChar.moveToLocation(Location.parseLoc(Util.joinStrings(" ", wordList, 1)), 0, true);
        } catch (IllegalArgumentException e) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        break;
      case admin_gonorth:
      case admin_gosouth:
      case admin_goeast:
      case admin_gowest:
      case admin_goup:
      case admin_godown:
        int val = wordList.length < 2 ? 150 : Integer.parseInt(wordList[1]);
        int x = activeChar.getX();
        int y = activeChar.getY();
        int z = activeChar.getZ();
        if (command == Commands.admin_goup) z += val;
        else if (command == Commands.admin_godown) z -= val;
        else if (command == Commands.admin_goeast) x += val;
        else if (command == Commands.admin_gowest) x -= val;
        else if (command == Commands.admin_gosouth) y += val;
        else if (command == Commands.admin_gonorth) y -= val;

        activeChar.teleToLocation(x, y, z);
        showTeleportWindow(activeChar);
        break;
      case admin_tele:
        showTeleportWindow(activeChar);
        break;
      case admin_teleto:
      case admin_tele_to:
      case admin_instant_move:
        if (wordList.length > 1 && wordList[1].equalsIgnoreCase("r")) activeChar.setTeleMode(2);
        else if (wordList.length > 1 && wordList[1].equalsIgnoreCase("end"))
          activeChar.setTeleMode(0);
        else activeChar.setTeleMode(1);
        break;
      case admin_tonpc:
      case admin_to_npc:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //tonpc npcId|npcName");
          return false;
        }
        String npcName = Util.joinStrings(" ", wordList, 1);
        NpcInstance npc;
        try {
          if ((npc = GameObjectsStorage.getByNpcId(Integer.parseInt(npcName))) != null) {
            teleportToCharacter(activeChar, npc);
            return true;
          }
        } catch (Exception e) {
        }
        if ((npc = GameObjectsStorage.getNpc(npcName)) != null) {
          teleportToCharacter(activeChar, npc);
          return true;
        }
        activeChar.sendMessage("Npc " + npcName + " not found");
        break;
      case admin_toobject:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //toobject objectId");
          return false;
        }
        Integer target = Integer.parseInt(wordList[1]);
        GameObject obj;
        if ((obj = GameObjectsStorage.findObject(target)) != null) {
          teleportToCharacter(activeChar, obj);
          return true;
        }
        activeChar.sendMessage("Object " + target + " not found");
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditChar) return false;

    switch (command) {
      case admin_teleport_character:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport_character x y z");
          return false;
        }
        teleportCharacter(activeChar, Util.joinStrings(" ", wordList, 1));
        showTeleportCharWindow(activeChar);
        break;
      case admin_recall:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //recall charName");
          return false;
        }
        String targetName = Util.joinStrings(" ", wordList, 1);
        Player recall_player = GameObjectsStorage.getPlayer(targetName);
        if (recall_player != null) {
          teleportTo(activeChar, recall_player, activeChar.getLoc(), activeChar.getReflectionId());
          return true;
        }
        int obj_id = CharacterDAO.getInstance().getObjectIdByName(targetName);
        if (obj_id > 0) {
          teleportCharacter_offline(obj_id, activeChar.getLoc());
          activeChar.sendMessage(targetName + " is offline. Offline teleport used...");
        } else activeChar.sendMessage("->" + targetName + "<- is incorrect.");
        break;
      case admin_setref:
        {
          if (wordList.length < 2) {
            activeChar.sendMessage("Usage: //setref <reflection>");
            return false;
          }

          int ref_id = Integer.parseInt(wordList[1]);
          if (ref_id != 0 && ReflectionManager.getInstance().get(ref_id) == null) {
            activeChar.sendMessage("Reflection <" + ref_id + "> not found.");
            return false;
          }

          GameObject target = activeChar;
          GameObject obj = activeChar.getTarget();
          if (obj != null) target = obj;

          target.setReflection(ref_id);
          target.decayMe();
          target.spawnMe();
          break;
        }
      case admin_getref:
        if (wordList.length < 2) {
          activeChar.sendMessage("Usage: //getref <char_name>");
          return false;
        }
        Player cha = GameObjectsStorage.getPlayer(wordList[1]);
        if (cha == null) {
          activeChar.sendMessage("Player '" + wordList[1] + "' not found in world");
          return false;
        }
        activeChar.sendMessage(
            "Player '"
                + wordList[1]
                + "' in reflection: "
                + activeChar.getReflectionId()
                + ", name: "
                + activeChar.getReflection().getName());
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditNPC) return false;

    switch (command) {
      case admin_recall_npc:
        recallNPC(activeChar);
        break;
      default:
        break;
    }

    return true;
  }