public void cancelRegisteredItem(Player player, int brokerItemId) {
    if (player.getInventory().isFull()) {
      PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(901298));
      return;
    }
    int playerId = player.getObjectId();
    Map<Integer, BrokerItem> brokerItems = getRaceBrokerItems(player.getCommonData().getRace());
    BrokerItem brokerItem = brokerItems.get(brokerItemId);

    if (brokerItem == null) return;
    if (playerId != brokerItem.getSellerId()) {
      Logger.getLogger(this.getClass())
          .info(
              "[AUDIT]Player: "
                  + player.getName()
                  + " is trying to steal: "
                  + brokerItem.getItemId()
                  + " => Hacking!");
      return;
    }
    synchronized (brokerItem) {
      if (brokerItem != null) {
        Item item = player.getInventory().putToBag(brokerItem.getItem());
        PacketSendUtility.sendPacket(player, new SM_INVENTORY_UPDATE(item, true));
        PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(brokerItemId, 4));
        brokerItem.setPersistentState(PersistentState.DELETED);
        saveManager.add(new BrokerOpSaveTask(brokerItem));
        brokerItems.remove(brokerItemId);
      }
      showRegisteredItems(player);
    }
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs == null || qs.getStatus() == QuestStatus.NONE) {
      if (env.getDialogId() == 1002) {
        QuestService.startQuest(env, QuestStatus.START);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      } else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
    }
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);

    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 798316) {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 2375);
        else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5);
        else return defaultQuestEndDialog(env);
      }
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 278591) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 0) return sendQuestDialog(env, 1352);
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    } else if (targetId == 278624) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 1) return sendQuestDialog(env, 1693);
        case 10001:
          if (var == 1) {
            qs.setQuestVarById(0, var + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (targetId == 203550) // Munin
    {
      if (qs == null || qs.getStatus() == QuestStatus.START) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
        else if (env.getDialogId() == 10000) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return defaultQuestStartDialog(env);
      } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) // Reward
      {
        if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
        else if (env.getDialogId() == 1009) defaultQuestRemoveItem(env, 182207085, 1);
        return defaultQuestEndDialog(env);
      }
    } else if (targetId == 203546) // Skuld
    {

      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
        if (env.getDialogId() == 26) return sendQuestDialog(env, 1352);
        else if (env.getDialogId() == 10001) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(env);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return defaultQuestStartDialog(env);
      }

    } else if (targetId == 279034) // Baoninerk
    {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 2) {
        switch (env.getDialogId()) {
          case 26:
            return sendQuestDialog(env, 1693);
          case 34:
            return defaultQuestItemCheck(env, 2, 0, true, 10000, 10001, 182207085, 1);
        }
      }
    } else if (qs != null && qs.getStatus() == QuestStatus.START) {
      switch (targetId) {
        case 700509: // Shining Box
        case 700510: // Balaur Supply Box
          {
            if (qs.getQuestVarById(0) == 2 && env.getDialogId() == -1) return true;
          }
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    final int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs.getStatus() == QuestStatus.START) {
      switch (targetId) {
        case 203665:
          switch (env.getDialogId()) {
            case 25:
              if (var == 0) return sendQuestDialog(env, 1011);
              break;
            case 10000:
              if (var == 0) {
                qs.setQuestVarById(0, var + 1);
                updateQuestStatus(env);
                PacketSendUtility.sendPacket(
                    player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                return true;
              }
          }
          break;
        case 203668:
          switch (env.getDialogId()) {
            case 25:
              if (var == 1) return sendQuestDialog(env, 1352);
              else if (var == 5) return sendQuestDialog(env, 1693);
              else if (var == 6) return sendQuestDialog(env, 2034);
              break;
            case 10001:
            case 10002:
              if (var == 1 || var == 5) {
                qs.setQuestVarById(0, var + 1);
                updateQuestStatus(env);
                PacketSendUtility.sendPacket(
                    player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
                return true;
              }
            case 33:
              if (var == 6) {
                if (QuestService.collectItemCheck(env, true)) {
                  qs.setStatus(QuestStatus.REWARD);
                  updateQuestStatus(env);
                  return sendQuestDialog(env, 5);
                } else return sendQuestDialog(env, 2120);
              }
          }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203668) return defaultQuestEndDialog(env);
    }
    return false;
  }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null || qs.getStatus() == QuestStatus.NONE) {
     if (targetId == 203590) {
       if (env.getDialogId() == 25) return sendQuestDialog(env, 1011);
       else if (env.getDialogId() == 1002) {
         if (ItemService.addItems(player, Collections.singletonList(new QuestItems(182203257, 1))))
           return defaultQuestStartDialog(env);
         return true;
       } else return defaultQuestStartDialog(env);
     }
   }
   if (qs == null) return false;
   int var = qs.getQuestVarById(0);
   if (qs.getStatus() == QuestStatus.START || qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 203591) {
       if (var == 0) {
         if (env.getDialogId() == 25) return sendQuestDialog(env, 1352);
         else if (env.getDialogId() == 10000) {
           qs.setQuestVar(1);
           updateQuestStatus(env);
           PacketSendUtility.sendPacket(
               player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
           return true;
         }
       }
       if (var == 2 || var == 3) {
         if (env.getDialogId() == 25) return sendQuestDialog(env, 2375);
         else if (env.getDialogId() == 1009) {
           qs.setQuestVar(3);
           qs.setStatus(QuestStatus.REWARD);
           updateQuestStatus(env);
           return defaultQuestEndDialog(env);
         } else return defaultQuestEndDialog(env);
       }
     } else if (targetId == 203557) {
       if (var == 1) {
         if (env.getDialogId() == 25) return sendQuestDialog(env, 1693);
         else if (env.getDialogId() == 10001) {
           qs.setQuestVar(2);
           updateQuestStatus(env);
           player.getInventory().removeFromBagByItemId(182203257, 1);
           PacketSendUtility.sendPacket(
               player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
           return true;
         }
       }
     }
   }
   return false;
 }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (targetId == 204193) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
       else if (env.getDialogId() == 1002) {
         if (ItemService.addItems(player, Collections.singletonList(new QuestItems(182207006, 1))))
           return defaultQuestStartDialog(env);
         return true;
       } else return defaultQuestStartDialog(env);
     }
   } else if (targetId == 204170) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1352);
       else if (env.getDialogId() == 10000) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
         return true;
       }
     }
   } else if (targetId == 798065) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1693);
       else if (env.getDialogId() == 10001) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
         return true;
       }
     }
   } else if (targetId == 204173) {
     if (qs != null) {
       if (env.getDialogId() == 26 && qs.getStatus() == QuestStatus.START)
         return sendQuestDialog(env, 2375);
       else if (env.getDialogId() == 1009) {
         qs.setQuestVar(3);
         qs.setStatus(QuestStatus.REWARD);
         updateQuestStatus(env);
         return defaultQuestEndDialog(env);
       } else return defaultQuestEndDialog(env);
     }
   }
   return false;
 }
Exemple #7
0
 @Override
 public boolean onDialogEvent(QuestEnv env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (targetId == 798126) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1011);
       else return sendQuestStartDialog(env);
     }
   } else if (targetId == 203940) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
       if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1352);
       else if (env.getDialog() == QuestDialog.STEP_TO_1) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return sendQuestStartDialog(env);
     }
   } else if (targetId == 203944) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
       if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1352);
       else if (env.getDialog() == QuestDialog.STEP_TO_1) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 1693));
         return true;
       } else return sendQuestStartDialog(env);
     }
   } else if (targetId == 798127) {
     if (qs != null) {
       if (env.getDialog() == QuestDialog.START_DIALOG && qs.getStatus() == QuestStatus.START)
         return sendQuestDialog(env, 2375);
       else if (env.getDialogId() == 1009
           && qs.getStatus() != QuestStatus.COMPLETE
           && qs.getStatus() != QuestStatus.NONE) {
         qs.setQuestVar(3);
         qs.setStatus(QuestStatus.REWARD);
         updateQuestStatus(env);
         return sendQuestEndDialog(env);
       } else return sendQuestEndDialog(env);
     }
   }
   return false;
 }
  /**
   * Calculates the fall damage
   *
   * @param player
   * @param distance
   * @return True if the player is forced to his bind location.
   */
  public static boolean calculateFallDamage(Player player, float distance) {
    if (player.isInvul()) {
      return false;
    }

    if (distance >= FallDamageConfig.MAXIMUM_DISTANCE_DAMAGE) {
      player.getController().onStopMove();
      player.getFlyController().onStopGliding();
      player.getController().onDie(player);

      if (player.getKisk() != null) player.getReviveController().kiskRevive();
      else player.getReviveController().bindRevive();
      return true;
    } else if (distance >= FallDamageConfig.MINIMUM_DISTANCE_DAMAGE) {
      float dmgPerMeter =
          player.getLifeStats().getMaxHp() * FallDamageConfig.FALL_DAMAGE_PERCENTAGE / 100f;
      int damage = (int) (distance * dmgPerMeter);

      player.getLifeStats().reduceHp(damage, player);
      PacketSendUtility.sendPacket(
          player, new SM_ATTACK_STATUS(player, SM_ATTACK_STATUS.TYPE.FALL_DAMAGE, -damage));
    }

    return false;
  }
Exemple #9
0
 @Override
 public void updateStatInfo() {
   Player master = owner.getMaster();
   if (master != null) {
     PacketSendUtility.sendPacket(master, new SM_SUMMON_UPDATE(owner));
   }
 }
  @Override
  public boolean onDialogEvent(QuestCookie env) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    if (targetId == 0) {
      if (env.getDialogId() == 1002) {
        QuestService.startQuest(env, QuestStatus.START);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      }
    } else if (targetId == 799939) // Emma
    {
      if (qs != null) {
        if (env.getDialogId() == 26 && qs.getStatus() == QuestStatus.START) {
          return sendQuestDialog(env, 2375);
        } else if (env.getDialogId() == 1009) {
          qs.setQuestVar(1);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(env);
          return defaultQuestEndDialog(env);
        } else return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_SENDFAKESERVERPACKET) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }

    if (params.length < 3) {
      PacketSendUtility.sendMessage(admin, "Incorrent number of params in //fsc command");
      return;
    }

    int id = Integer.decode(params[0]);
    String format = "";

    if (params.length > 1) format = params[1];

    SM_CUSTOM_PACKET packet = new SM_CUSTOM_PACKET(id);

    int i = 0;
    for (char c : format.toCharArray()) {
      packet.addElement(PacketElementType.getByCode(c), params[i + 2]);
      i++;
    }
    PacketSendUtility.sendPacket(admin, packet);
  }
Exemple #12
0
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs.getStatus() == QuestStatus.START) {
      if (targetId == 203129) {
        switch (env.getDialog()) {
          case START_DIALOG:
            if (var == 0) return sendQuestDialog(env, 1011);
          case STEP_TO_1:
          case STEP_TO_2:
            if (var == 0) {
              qs.setQuestVarById(0, var + 1);
              updateQuestStatus(env);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return true;
            }
        }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 203129) return sendQuestEndDialog(env);
    }
    return false;
  }
Exemple #13
0
  public static boolean questTimerStart(QuestCookie env, int timeInSeconds) {
    final Player player = env.getPlayer();
    final int id = env.getQuestId();

    if (!player.getQuestTimerOn()) {
      // Schedule Action When Timer Finishes
      Future<?> task =
          ThreadPoolManager.getInstance()
              .schedule(
                  new Runnable() {

                    @Override
                    public void run() {
                      player.setQuestTimerOn(false);
                      QuestEngine.getInstance()
                          .onQuestTimerEnd(new QuestCookie(null, player, 0, 0));
                      if (QuestEngine.getInstance().deleteQuest(player, id))
                        PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(id));
                      player.getController().updateNearbyQuests();
                    }
                  },
                  timeInSeconds * 1000);
      player.setQuestTimerOn(true);
      player.getController().addTask(TaskId.QUEST_TIMER, task);
      PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(4, id, timeInSeconds));
      return true;
    }
    return false;
  }
 @Override
 public boolean onDialogEvent(final QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null) {
     if (targetId == 205130) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
       else return defaultQuestStartDialog(env);
     }
   } else if (qs.getStatus() == QuestStatus.START) {
     switch (targetId) {
       case 730107:
         {
           if (qs.getQuestVarById(0) == 0 && env.getDialogId() == -1) {
             final int targetObjectId = env.getVisibleObject().getObjectId();
             PacketSendUtility.sendPacket(
                 player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
             PacketSendUtility.broadcastPacket(
                 player,
                 new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId),
                 true);
             ThreadPoolManager.getInstance()
                 .schedule(
                     new Runnable() {
                       @Override
                       public void run() {
                         if (!player.isTargeting(targetObjectId)) return;
                         PacketSendUtility.sendPacket(
                             player,
                             new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                         PacketSendUtility.broadcastPacket(
                             player,
                             new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                             true);
                         qs.setQuestVarById(0, 1);
                         updateQuestStatus(env);
                       }
                     },
                     3000);
           }
         }
       case 205130:
         {
           if (qs.getQuestVarById(0) == 1) {
             if (env.getDialogId() == 26) return sendQuestDialog(env, 2375);
             else if (env.getDialogId() == 1009) {
               qs.setStatus(QuestStatus.REWARD);
               updateQuestStatus(env);
               return defaultQuestEndDialog(env);
             } else return defaultQuestEndDialog(env);
           }
         }
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 205130) return defaultQuestEndDialog(env);
   }
   return false;
 }
Exemple #15
0
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    if (targetId == 0) {
      if (env.getDialogId() == 1002) {
        QuestService.startQuest(env);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      }
    } else if (targetId == 278055) {
      if (qs != null) {
        if (env.getDialog() == QuestDialog.START_DIALOG && qs.getStatus() == QuestStatus.START) {
          return sendQuestDialog(env, 2375);
        } else if (env.getDialogId() == 1009
            && qs.getStatus() != QuestStatus.COMPLETE
            && qs.getStatus() != QuestStatus.NONE) {
          removeQuestItem(env, 182207044, 1);
          qs.setQuestVar(1);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(env);
          return sendQuestEndDialog(env);
        } else return sendQuestEndDialog(env);
      }
    }
    return false;
  }
Exemple #16
0
 @Override
 protected void onInteractionStart() {
   PacketSendUtility.sendPacket(
       requestor, new SM_CRAFT_UPDATE(recipeTemplate.getSkillid(), itemTemplate, 100, 100, 0));
   PacketSendUtility.sendPacket(
       requestor, new SM_CRAFT_UPDATE(recipeTemplate.getSkillid(), itemTemplate, 0, 0, 1));
   PacketSendUtility.broadcastPacket(
       requestor,
       new SM_CRAFT_ANIMATION(
           requestor.getObjectId(), responder.getObjectId(), recipeTemplate.getSkillid(), 0),
       true);
   PacketSendUtility.broadcastPacket(
       requestor,
       new SM_CRAFT_ANIMATION(
           requestor.getObjectId(), responder.getObjectId(), recipeTemplate.getSkillid(), 1),
       true);
 }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   if (env.getPlayer().getTribe().equals("PC_DARK")) {
     final Player player = env.getPlayer();
     int targetId = 0;
     if (env.getVisibleObject() instanceof Npc)
       targetId = ((Npc) env.getVisibleObject()).getNpcId();
     QuestTemplate template = DataManager.QUEST_DATA.getQuestById(questId);
     QuestState qs = player.getQuestStateList().getQuestState(questId);
     if (targetId == 730330) {
       PlayerClass playerClass = player.getCommonData().getPlayerClass();
       if (playerClass == PlayerClass.RANGER
           || playerClass == PlayerClass.ASSASSIN
           || playerClass == PlayerClass.MAGE
           || playerClass == PlayerClass.PRIEST
           || playerClass == PlayerClass.GLADIATOR
           || playerClass == PlayerClass.WARRIOR
           || playerClass == PlayerClass.SCOUT) {
         if (qs == null
             || qs.getStatus() == QuestStatus.NONE
             || (qs.getStatus() == QuestStatus.COMPLETE
                 && (qs.getCompleteCount() <= template.getMaxRepeatCount()))) {
           if (env.getDialogId() == -1) return sendQuestDialog(env, 1011);
           else return defaultQuestStartDialog(env);
         } else if (qs != null
             && qs.getStatus() == QuestStatus.START
             && qs.getQuestVarById(0) == 0) {
           if (env.getDialogId() == -1) return sendQuestDialog(env, 2375);
           else if (env.getDialogId() == 34) {
             if (player.getInventory().getItemCountByItemId(185000102) >= 1) {
               player.getInventory().removeFromBagByItemId(185000102, 1);
               qs.setStatus(QuestStatus.REWARD);
               qs.setQuestVar(1);
               qs.setCompliteCount(0);
               updateQuestStatus(env);
               return sendQuestDialog(env, 5);
             } else return sendQuestDialog(env, 2716);
           }
         } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
           int var = qs.getQuestVarById(0);
           switch (env.getDialogId()) {
             case -1:
               if (var == 1) return sendQuestDialog(env, 5);
             case 17:
               QuestService.questFinish(env, qs.getQuestVars().getQuestVars() - 1);
               PacketSendUtility.sendPacket(
                   player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
               return true;
           }
         }
       }
       return false;
     }
     return false;
   } else {
     return false;
   }
 }
Exemple #18
0
  public static boolean questTimerEnd(QuestCookie env) {
    final Player player = env.getPlayer();
    final int id = env.getQuestId();

    player.setQuestTimerOn(false);
    player.getController().cancelTask(TaskId.QUEST_TIMER);
    PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(4, id, 0));
    return true;
  }
  private void putToSettled(Race race, BrokerItem brokerItem, boolean isSold) {
    if (isSold) brokerItem.removeItem();
    else brokerItem.setSettled();

    brokerItem.setPersistentState(PersistentState.UPDATE_REQUIRED);

    switch (race) {
      case ASMODIANS:
        asmodianSettledItems.put(brokerItem.getItemUniqueId(), brokerItem);
        break;

      case ELYOS:
        elyosSettledItems.put(brokerItem.getItemUniqueId(), brokerItem);
        break;
    }

    Player seller = World.getInstance().findPlayer(brokerItem.getSellerId());

    saveManager.add(new BrokerOpSaveTask(brokerItem));

    if (seller != null) {
      Map<Integer, BrokerItem> brokerSettledItems =
          getRaceBrokerSettledItems(seller.getCommonData().getRace());

      int playerId = seller.getObjectId();

      List<BrokerItem> settledItems = new ArrayList<BrokerItem>();

      long totalKinah = 0;

      for (BrokerItem item : brokerSettledItems.values()) {
        if (item != null && playerId == item.getSellerId()) {
          settledItems.add(item);

          if (item.isSold()) totalKinah += item.getPrice();
        }
      }

      DescriptionId desId = new DescriptionId(brokerItem.getItem().getNameID());
      PacketSendUtility.sendPacket(seller, new SM_SYSTEM_MESSAGE(1301047, desId));
      showRegisteredItems(seller);
      PacketSendUtility.sendPacket(seller, new SM_BROKER_ITEMS(null, totalKinah, 2, 5));
    }
  }
 @Override
 public boolean onDialogEvent(QuestCookie env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (targetId == 798928) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 4762);
       else return defaultQuestStartDialog(env);
     } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
       if (env.getDialogId() == -1) return sendQuestDialog(env, 10002);
       else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5);
       else return defaultQuestEndDialog(env);
     }
   } else if (targetId == 799069) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
       if (env.getDialogId() == 26) return sendQuestDialog(env, 1011);
       else if (env.getDialogId() == 10000) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return defaultQuestStartDialog(env);
     }
   } else if (targetId == 700948) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
       if (env.getDialogId() == -1) {
         if (!ItemService.addItems(
             player, Collections.singletonList(new QuestItems(182202193, 1)))) return true;
         final int targetObjectId = env.getVisibleObject().getObjectId();
         PacketSendUtility.sendPacket(
             player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
         PacketSendUtility.broadcastPacket(
             player, new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId), true);
         qs.setQuestVar(2);
         updateQuestStatus(env);
       }
     }
   }
   return false;
 }
Exemple #21
0
 @Override
 protected void onComboStart() {
   PacketSendUtility.sendPacket(
       requestor, new SM_CRAFT_UPDATE(recipeTemplate.getSkillid(), itemTemplate, 75, 100, 3));
   PacketSendUtility.broadcastPacket(
       requestor,
       new SM_CRAFT_ANIMATION(
           requestor.getObjectId(), responder.getObjectId(), recipeTemplate.getSkillid(), 5),
       true);
 }
  public void onDialogSelect(int paramInt1, Player player, int paramInt2) {
    Npc target = getOwner();
    Object localObject;
    PlayerGroup playergroup = player.getPlayerGroup();
    int i = target.getObjectId().intValue();
    switch (getOwner().getNpcId()) {
      case 730291:
      case 730293:
        switch (paramInt1) {
          case 10000:
            int j = 0;
            if (player.getCommonData().getRace() == Race.ASMODIANS) j = 185000090;
            else j = 185000089;
            if (hasItem(player, j)) {
              Item item = player.getInventory().getFirstItemByItemId(j);
              if (item == null) return;

              player.getInventory().removeFromBag(item, true);
              PacketSendUtility.sendPacket(
                  player, new SM_DELETE_ITEM(item.getObjectId().intValue()));
              if (player.getPlayerGroup() == null || player.getLevel() < 50) {
                PacketSendUtility.sendPacket(
                    player, SM_SYSTEM_MESSAGE.STR_MSG_ENTER_ONLY_PARTY_DON);
                return;
              }
              int r = WorldMapType.IDDRAMATA_01.getId();
              localObject =
                  InstanceService.getRegisteredInstance(r, player.getObjectId().intValue());
              if (localObject != null) {
                transfer(player, (WorldMapInstance) localObject);
                return;
              }
              port(player, r);
              return;
            } else {
              PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(i, 1012));
            }
            return;
        }
        return;
    }
  }
 public void onDialogRequest(Player player) {
   getOwner().getAi().handleEvent(Event.TALK);
   Npc target = getOwner();
   int i = target.getObjectId().intValue();
   switch (getOwner().getNpcId()) {
     case 730291:
     case 730293:
       PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(i, 1011));
       return;
   }
 }
Exemple #24
0
 @Override
 protected void sendInteractionUpdate() {
   PacketSendUtility.sendPacket(
       requestor,
       new SM_CRAFT_UPDATE(
           recipeTemplate.getSkillid(),
           itemTemplate,
           currentSuccessValue,
           currentFailureValue,
           setCritical ? 2 : 1));
 }
  public void unsetAbnormal(int mask) {
    int count = 0;
    for (Effect effect : abnormalEffectMap.values()) {
      if ((effect.getAbnormals() & mask) == mask) count++;
    }
    if (count <= 1) abnormals &= ~mask;

    if (owner instanceof Player) {
      PacketSendUtility.sendPacket((Player) owner, new SM_SKILL_LIST((Player) owner));
    }
  }
Exemple #26
0
 @Override
 protected void onFailureFinish() {
   PacketSendUtility.sendPacket(
       requestor,
       new SM_CRAFT_UPDATE(
           recipeTemplate.getSkillid(),
           itemTemplate,
           currentSuccessValue,
           currentFailureValue,
           6));
   PacketSendUtility.broadcastPacket(
       requestor,
       new SM_CRAFT_ANIMATION(requestor.getObjectId(), responder.getObjectId(), 0, 3),
       true);
   PacketSendUtility.sendPacket(
       requestor,
       SM_SYSTEM_MESSAGE.STR_COMBINE_FAIL(
           new DescriptionId(
               ItemService.getItemTemplate(recipeTemplate.getProductid()).getNameId())));
 }
Exemple #27
0
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (targetId == 799025) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1011);
        else return sendQuestStartDialog(env);
      }
    }
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 799025) {
        return sendQuestEndDialog(env);
      }
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 799026) {
      switch (env.getDialog()) {
        case START_DIALOG:
          if (var == 0) return sendQuestDialog(env, 1352);
        case STEP_TO_1:
          if (var == 0) {
            if (giveQuestItem(env, 182206858, 1)) qs.setQuestVarById(0, var + 1);
            updateQuestStatus(env);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    } else if (targetId == 799025) {
      switch (env.getDialog()) {
        case START_DIALOG:
          if (var == 1) return sendQuestDialog(env, 2375);
        case SELECT_REWARD:
          if (var == 1) {
            removeQuestItem(env, 182206858, 1);
            qs.setQuestVarById(0, var + 1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(env);
            return sendQuestDialog(env, 5);
          }
          return false;
      }
    }
    return false;
  }
  public void onPlayerLogin(Player player) {
    Map<Integer, BrokerItem> brokerSettledItems =
        getRaceBrokerSettledItems(player.getCommonData().getRace());

    int playerId = player.getObjectId();

    List<BrokerItem> settledItems = new ArrayList<BrokerItem>();

    long totalKinah = 0;

    for (BrokerItem item : brokerSettledItems.values()) {
      if (item != null && playerId == item.getSellerId()) {
        settledItems.add(item);

        if (item.isSold()) totalKinah += item.getPrice();
      }
    }

    PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(null, totalKinah, 1, 5));
    if (totalKinah > 0) PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1400131));
  }
  @Override
  public void onDialogRequest(Player player) {
    // zer0patches todo check for better solution, portal data looks correct for portal controller
    // but
    // problem occurs because it is a quest teleportation via quest dialog on npc so portal check is
    // bypassed
    // Prevent Elyos's from using Aerolink in Gelkmaros -> Pandaemonium
    if (player.getCommonData().getRace() == Race.ELYOS && getOwner().getNpcId() == 730221) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MOVE_PORTAL_ERROR_INVALID_RACE);
      return;
    }
    // Prevent Asmodian's from using Aerolink in Inggison -> Sanctum
    if (player.getCommonData().getRace() == Race.ASMODIANS && getOwner().getNpcId() == 730220) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MOVE_PORTAL_ERROR_INVALID_RACE);
      return;
    }

    getOwner().getAi().handleEvent(Event.TALK);

    if (QuestEngine.getInstance().onDialog(new QuestCookie(getOwner(), player, 0, -1))) return;

    // Zephyr Deliveryman
    if (getOwner().getObjectId() == player.getZephyrObjectId()) {
      PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), 18));
      return;
    }

    int titleId = getOwner().getObjectTemplate().getTitleId();
    if ((
    // title ids of npcs
    titleId == 315018
        || titleId == 350474
        || titleId == 350473
        || titleId == 350212
        || titleId == 350304
        || titleId == 350305
        || titleId == 370000
        || titleId == 370003
        // aerolinks
        || (getOwner().getNpcId() >= 730265 && getOwner().getNpcId() <= 730269))) {
      NpcQuestData npcQD = QuestEngine.getInstance().getNpcQuestData(getOwner().getNpcId());
      QuestStateList list = player.getQuestStateList();
      List<Integer> events = npcQD.getOnTalkEvent();
      boolean hasQuestFromNpc = false;
      for (int e : events) {
        QuestState qs = list.getQuestState(e);
        if (qs != null && qs.getStatus() != QuestStatus.COMPLETE) {
          hasQuestFromNpc = true;
          break;
        } else {
          continue;
        }
      }
      if (hasQuestFromNpc)
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), 10));
      else
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), 1011));

    } else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), 10));
  }
Exemple #30
0
  public boolean questComplite(QuestCookie env) {
    Player player = env.getPlayer();
    int id = env.getQuestId();
    QuestState qs = player.getQuestStateList().getQuestState(id);
    if (qs == null || qs.getStatus() != QuestStatus.START) return false;

    qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
    qs.setStatus(QuestStatus.REWARD);
    PacketSendUtility.sendPacket(
        player, new SM_QUEST_ACCEPTED(2, id, qs.getStatus(), qs.getQuestVars().getQuestVars()));
    player.getController().updateNearbyQuests();
    return true;
  }