예제 #1
0
  @Override
  public void onDeath(Creature actor, Creature killer) {
    if (getOrderByTargetName(actor.getName()) != null
        && !actor.getName().equals(killer.getName())) {
      final Order order = getOrderByTargetName(actor.getName());
      Functions.addItem(killer.getPlayer(), order.getItemId(), order.getItemCount());
      Announcements.getInstance()
          .announceToAll(
              new CustomMessage(
                      "scripts.events.Hitman.AnnounceKill",
                      killer.getPlayer(),
                      killer.getName(),
                      actor.getName(),
                      order.getItemCount(),
                      ItemFunctions.createItem(order.getItemId()).getTemplate().getName())
                  .toString());

      if (order.getKillsCount() > 1) order.decrementKillsCount();
      else {
        _orderMap.remove(World.getPlayer(order.getOwner()).getObjectId());
        _inList.remove((Object) World.getPlayer(order.getOwner()).getObjectId());
        deleteFromDatabase(actor.getName());
      }
    }
  }
 private void updateAgression() {
   Player _player = World.getPlayer(agressor);
   if (_player != null) {
     if (agressors_pet != null
         && _player.getSummonList().getPet() != null
         && _player.getSummonList().getPet().getName().equalsIgnoreCase(agressors_pet))
       AddAgression(_player.getSummonList().getPet(), 10);
     AddAgression(_player, 2);
   }
   if (agressors_party != null)
     for (String _agressor : agressors_party) AddAgression(World.getPlayer(_agressor), 1);
 }
예제 #3
0
  public static int addOrder(
      Player player, String name, int killsCount, int itemcount, String itemname) {
    if (!checkPlayer(player)) return -1;

    if (Functions.getItemCount(player, Config.EVENT_HITMAN_COST_ITEM_ID)
        < Config.EVENT_HITMAN_COST_ITEM_COUNT) return 0;

    if (Functions.getItemCount(player, _allowedItems.get(itemname)) < itemcount) return 0;

    if (isRegistered(player)) return 1;

    if (World.getPlayer(name) == null) return 2;

    if (World.getPlayer(name).getObjectId() == player.getObjectId()) return 3;

    final Order order =
        new Order(player.getName(), name, _allowedItems.get(itemname), itemcount, killsCount);

    _orderMap.put(player.getObjectId(), order);
    _inList.add(0, player.getObjectId());
    saveToDatabase(
        player.getObjectId(),
        player.getName(),
        name,
        _allowedItems.get(itemname),
        itemcount,
        killsCount);
    Functions.removeItem(
        player, Config.EVENT_HITMAN_COST_ITEM_ID, Config.EVENT_HITMAN_COST_ITEM_COUNT);
    Functions.removeItem(player, _allowedItems.get(itemname), itemcount * killsCount);

    Announcements.getInstance()
        .announceToAll(
            new CustomMessage(
                    "scripts.events.Hitman.Announce",
                    player,
                    player.getName(),
                    itemcount,
                    itemname,
                    name)
                .toString());

    World.getPlayer(name).setIsOrdered(true);

    return 5;
  }
예제 #4
0
 public static boolean deleteOrder(int storedId) {
   if (!_orderMap.containsKey(storedId)) return false;
   Functions.addItem(
       World.getPlayer(storedId),
       _orderMap.get(storedId).getItemId(),
       _orderMap.get(storedId).getItemCount() * _orderMap.get(storedId).getKillsCount());
   _orderMap.remove(storedId);
   _inList.remove((Object) storedId);
   deleteFromDatabase(storedId);
   GameObjectsStorage.getPlayer(storedId).setIsOrdered(false);
   return true;
 }
예제 #5
0
 private Player getTargetChar(String[] wordList, int wordListIndex, Player activeChar) {
   // цель задана аргументом
   if (wordListIndex >= 0 && wordList.length > wordListIndex) {
     Player player = World.getPlayer(wordList[wordListIndex]);
     if (player == null) activeChar.sendMessage("Can't find player: " + wordList[wordListIndex]);
     return player;
   }
   // цель задана текущим таргетом
   GameObject my_target = activeChar.getTarget();
   if (my_target != null && my_target.isPlayer()) return (Player) my_target;
   // в качестве цели сам админ
   return activeChar;
 }