/** {@inheritDoc} */
  @Override
  protected void runImpl() {
    Player activePlayer = getConnection().getActivePlayer();

    Iterator<Player> it = World.getInstance().getPlayersIterator();

    List<Player> matches = new ArrayList<Player>(MAX_RESULTS);

    if (activePlayer != null && activePlayer.getLevel() < 10) {
      sendPacket(SM_SYSTEM_MESSAGE.LEVEL_NOT_ENOUGH_FOR_SEARCH("10"));
      return;
    }
    while (it.hasNext() && matches.size() < MAX_RESULTS) {
      Player player = it.next();
      if (!player.isSpawned()) continue;
      else if (player.getFriendList().getStatus() == Status.OFFLINE) continue;
      else if (lfgOnly == 1 && !player.isLookingForGroup()) continue;
      else if (!name.isEmpty() && !player.getName().toLowerCase().contains(name.toLowerCase()))
        continue;
      else if (minLevel != 0xFF && player.getLevel() < minLevel) continue;
      else if (maxLevel != 0xFF && player.getLevel() > maxLevel) continue;
      else if (classMask > 0 && (player.getPlayerClass().getMask() & classMask) == 0) continue;
      else if (region > 0 && player.getActiveRegion().getMapId() != region) continue;
      else if ((player.getCommonData().getRace() != activePlayer.getCommonData().getRace())
          && (CustomConfig.FACTIONS_SEARCH_MODE == false)) continue;
      else
      // This player matches criteria
      {
        matches.add(player);
      }
    }

    sendPacket(new SM_PLAYER_SEARCH(matches, region));
  }
  /** Instance will be destroyed All players moved to bind location All objects - deleted */
  private static void destroyInstance(WorldMapInstance instance) {
    instance.getEmptyInstanceTask().cancel(false);

    int worldId = instance.getMapId();
    int instanceId = instance.getInstanceId();

    WorldMap map = World.getInstance().getWorldMap(worldId);
    map.removeWorldMapInstance(instanceId);

    log.info("Destroying instance:" + worldId + " " + instanceId);

    Iterator<VisibleObject> it = instance.objectIterator();
    while (it.hasNext()) {
      VisibleObject obj = it.next();
      if (obj instanceof Player) {
        Player player = (Player) obj;
        PortalTemplate portal =
            DataManager.PORTAL_DATA.getInstancePortalTemplate(
                worldId, player.getCommonData().getRace());
        moveToEntryPoint((Player) obj, portal, true);
      } else {
        obj.getController().delete();
      }
    }
  }
Пример #3
0
 /**
  * Stores newly created player
  *
  * @param player player to store
  * @return true if character was successful saved.
  */
 public static boolean storeNewPlayer(Player player, String accountName, int accountId) {
   return DAOManager.getDAO(PlayerDAO.class)
           .saveNewPlayer(player.getCommonData(), accountId, accountName)
       && DAOManager.getDAO(PlayerAppearanceDAO.class).store(player)
       && DAOManager.getDAO(PlayerSkillListDAO.class).storeSkills(player)
       && DAOManager.getDAO(InventoryDAO.class).store(player.getDirtyItemsToUpdate())
       && DAOManager.getDAO(PlayerTitleListDAO.class).storeTitles(player);
 }
Пример #4
0
 private boolean setPlayerClass(QuestEnv env, QuestState qs, PlayerClass playerClass) {
   Player player = env.getPlayer();
   player.getCommonData().setPlayerClass(playerClass);
   player.getCommonData().upgradePlayer();
   qs.setStatus(QuestStatus.REWARD);
   updateQuestStatus(player, qs);
   sendQuestDialog(player, env.getVisibleObject().getObjectId(), 5);
   return true;
 }
Пример #5
0
 @Override
 public boolean onLvlUpEvent(QuestEnv env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null) return false;
   if (player.getCommonData().getLevel() < 9) return false;
   env.setQuestId(questId);
   questService.startQuest(env, QuestStatus.START);
   return true;
 }
  /**
   * @param player
   * @param portalTemplates
   */
  private static void moveToEntryPoint(
      Player player, PortalTemplate portalTemplate, boolean useTeleport) {
    EntryPoint entryPoint = null;
    List<EntryPoint> entryPoints = portalTemplate.getEntryPoint();

    for (EntryPoint point : entryPoints) {
      if (point.getRace() == null || point.getRace().equals(player.getCommonData().getRace())) {
        entryPoint = point;
        break;
      }
    }

    if (entryPoint == null) {
      log.warn(
          "Entry point not found for "
              + player.getCommonData().getRace()
              + " "
              + player.getWorldId());
      return;
    }

    if (useTeleport) {
      TeleportService.teleportTo(
          player,
          entryPoint.getMapId(),
          1,
          entryPoint.getX(),
          entryPoint.getY(),
          entryPoint.getZ(),
          0);
    } else {
      World.getInstance()
          .setPosition(
              player,
              entryPoint.getMapId(),
              1,
              entryPoint.getX(),
              entryPoint.getY(),
              entryPoint.getZ(),
              player.getHeading());
    }
  }
 @Override
 public boolean onLvlUpEvent(QuestEnv env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   boolean lvlCheck =
       QuestService.checkLevelRequirement(questId, player.getCommonData().getLevel());
   if (qs == null || !lvlCheck || qs.getStatus() != QuestStatus.LOCKED) return false;
   qs.setStatus(QuestStatus.START);
   updateQuestStatus(player, qs);
   return true;
 }
Пример #8
0
  /** Disponible des le level 10 * */
  public boolean onLvlUpEvent(QuestEnv env) {
    Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null
        || player.getCommonData().getLevel() < 10
        || qs.getStatus() != QuestStatus.LOCKED) return false;

    qs.setStatus(QuestStatus.START);
    updateQuestStatus(player, qs);
    return true;
  }
Пример #9
0
 /**
  * Constructs new <tt>SM_MESSAGE </tt> packet
  *
  * @param player who sent message
  * @param message actual message
  * @param chatType what chat type should be used
  */
 public SM_MESSAGE(Player player, String message, ChatType chatType) {
   this.player = player;
   this.senderObjectId = player.getObjectId();
   this.senderName = player.getName();
   this.message = message;
   this.race = player.getCommonData().getRace();
   this.chatType = chatType;
   this.x = player.getX();
   this.y = player.getY();
   this.z = player.getZ();
 }
Пример #10
0
 @Override
 public boolean onMovieEndEvent(QuestEnv env, int movieId) {
   if (movieId != 2) return false;
   Player player = env.getPlayer();
   if (player.getCommonData().getRace() != Race.ASMODIANS) return false;
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null || qs.getStatus() != QuestStatus.START) return false;
   qs.setStatus(QuestStatus.REWARD);
   QuestService.finishQuest(env);
   return true;
 }
Пример #11
0
  /**
   * This method is called when player leaves the game, which includes just two cases: either player
   * goes back to char selection screen or it's leaving the game [closing client].<br>
   * <br>
   * <b><font color='red'>NOTICE: </font> This method is called only from {@link AionConnection} and
   * {@link CM_QUIT} and must not be called from anywhere else</b>
   *
   * @param player
   */
  public static void playerLoggedOut(final Player player) {
    log.info(
        "Player logged out: "
            + player.getName()
            + " Account: "
            + player.getClientConnection().getAccount().getName());
    player.onLoggedOut();

    // Update prison timer
    if (player.isInPrison()) {
      long prisonTimer = System.currentTimeMillis() - player.getStartPrison();
      prisonTimer = player.getPrisonTimer() - prisonTimer;

      player.setPrisonTimer(prisonTimer);

      log.debug("Update prison timer to " + prisonTimer / 1000 + " seconds !");
    }

    // store current effects
    DAOManager.getDAO(PlayerEffectsDAO.class).storePlayerEffects(player);
    DAOManager.getDAO(ItemCooldownsDAO.class).storeItemCooldowns(player);
    DAOManager.getDAO(PlayerLifeStatsDAO.class).updatePlayerLifeStat(player);
    player.getEffectController().removeAllEffects();

    player.getLifeStats().cancelAllTasks();

    if (player.getLifeStats().isAlreadyDead()) TeleportService.moveToBindLocation(player, false);

    if (DuelService.getInstance().isDueling(player.getObjectId()))
      DuelService.getInstance().loseDuel(player);

    if (player.getSummon() != null) player.getSummon().getController().release(UnsummonType.LOGOUT);

    PunishmentService.stopPrisonTask(player, true);

    player.getCommonData().setOnline(false);
    player.getCommonData().setLastOnline(new Timestamp(System.currentTimeMillis()));

    player.setClientConnection(null);

    if (player.isLegionMember()) LegionService.getInstance().onLogout(player);

    if (player.isInGroup()) GroupService.getInstance().scheduleRemove(player);

    if (player.isInAlliance()) AllianceService.getInstance().onLogout(player);

    player.getController().delete();
    DAOManager.getDAO(PlayerDAO.class).onlinePlayer(player, false);

    if (!GSConfig.DISABLE_CHAT_SERVER) ChatService.onPlayerLogout(player);

    storePlayer(player);
    player.getEquipment().setOwner(null);
  }
Пример #12
0
 /**
  * This method is called just after player logged in to the game.<br>
  * <br>
  * <b><font color='red'>NOTICE: </font> This method called only from {@link CM_ENTER_WORLD} and
  * must not be called from anywhere else.</b>
  *
  * @param player
  */
 public static void playerLoggedIn(Player player) {
   log.info(
       "Player logged in: "
           + player.getName()
           + " Account: "
           + player.getClientConnection().getAccount().getName());
   player.getCommonData().setOnline(true);
   DAOManager.getDAO(PlayerDAO.class).onlinePlayer(player, true);
   player.getFriendList().setStatus(Status.ONLINE);
   player.onLoggedIn();
 }
Пример #13
0
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    Player activePlayer = getConnection().getActivePlayer();

    if (!note.equals(activePlayer.getCommonData().getNote())) {

      activePlayer.getCommonData().setNote(note);

      for (Friend friend : activePlayer.getFriendList()) // For all my friends
      {

        if (friend.isOnline()) // If the player is online
        {
          friend
              .getPlayer()
              .getClientConnection()
              .sendPacket(new SM_FRIEND_LIST()); // Send him a new friend list packet
        }
      }
    }
  }
  @Override
  public boolean onLvlUpEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    boolean lvlCheck =
        QuestService.checkLevelRequirement(questId, player.getCommonData().getLevel());
    if (qs != null || !lvlCheck) return false;

    env.setQuestId(questId);
    QuestService.startQuest(env, QuestStatus.START);
    return true;
  }
 /**
  * @param player
  * @param target
  * @return XP reward from target
  */
 public static long calculateSoloExperienceReward(Player player, Creature target) {
   int playerLevel = player.getCommonData().getLevel();
   int targetLevel = target.getLevel();
   // int baseXP = ((Npc) target).getObjectTemplate().getStatsTemplate().getMaxXp();
   int baseXP =
       getBaseXp(
           ((Npc) target).getObjectTemplate().getStatsTemplate().getMaxXp(),
           ((Npc) target).getObjectTemplate().getStatsTemplate().getMaxHp());
   int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);
   long rewardXP = Math.round(baseXP * (xpPercentage / 100d));
   return rewardXP;
 }
  /**
   * @param player
   * @param target
   * @return DP reward
   */
  public static int calculateGroupDPReward(Player player, Creature target) {
    int playerLevel = player.getCommonData().getLevel();
    int targetLevel = target.getLevel();
    NpcRating npcRating = ((Npc) target).getObjectTemplate().getRating();

    // TODO: fix to see monster Rating level, NORMAL lvl 1, 2 | ELITE lvl 1, 2 etc..
    int baseDP = targetLevel * calculateRatingMultipler(npcRating);
    int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);
    float rate = player.getRates().getDpNpcRate();

    return (int) Math.floor(baseDP * xpPercentage * rate / 100);
  }
  /**
   * @param player
   * @param target
   * @return AP reward
   */
  public static int calculatePvEGpGained(Player player, Creature target) {
    float gpPercentage =
        target.isRaidMonster()
            ? 100f
            : APRewardEnum.apReward(player.getAbyssRank().getRank().getId());
    boolean lvlDiff = player.getCommonData().getLevel() - target.getLevel() > 10;
    float gpNpcRate = GpNpcRating(((Npc) target).getObjectTemplate().getRating());

    return (int)
        (lvlDiff
            ? 1
            : RewardType.GP_NPC.calcReward(
                player, (int) Math.floor(15 * gpPercentage * gpNpcRate / 100)));
  }
  /**
   * ref:
   * http://www.aionsource.com/forum/mechanic-analysis/42597-character-stats-xp-dp-origin-gerbator-team-july-2009-
   * a.html
   *
   * @param player
   * @param target
   * @return DP reward from target
   */
  public static int calculateSoloDPReward(Player player, Creature target) {
    int playerLevel = player.getCommonData().getLevel();
    int targetLevel = target.getLevel();
    NpcRating npcRating = ((Npc) target).getObjectTemplate().getRating();

    // TODO: fix to see monster Rating level, NORMAL lvl 1, 2 | ELITE lvl 1, 2 etc..
    // look at:
    // http://www.aionsource.com/forum/mechanic-analysis/42597-character-stats-xp-dp-origin-gerbator-team-july-2009-a.html
    int baseDP = targetLevel * calculateRatingMultipler(npcRating);

    int xpPercentage = XPRewardEnum.xpRewardFrom(targetLevel - playerLevel);
    float rate = player.getRates().getDpNpcRate();
    return (int) Math.floor(baseDP * xpPercentage * rate / 100);
  }
  @Override
  public boolean onLvlUpEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null
        || qs.getStatus() != QuestStatus.LOCKED
        || player.getCommonData().getLevel() < 38) return false;

    QuestState qs2 = player.getQuestStateList().getQuestState(1500);
    if (qs2 == null || qs2.getStatus() != QuestStatus.COMPLETE) return false;
    qs.setStatus(QuestStatus.START);
    updateQuestStatus(player, qs);
    return true;
  }
 @Override
 public boolean onMovieEndEvent(QuestEnv env, int movieId) {
   if (movieId != 16) return false;
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null || qs.getStatus() != QuestStatus.REWARD) return false;
   int rewardExp = player.getRates().getQuestXpRate() * 8410;
   player.getCommonData().addExp(rewardExp);
   qs.setStatus(QuestStatus.COMPLETE);
   qs.setCompliteCount(1);
   updateQuestStatus(player, qs);
   PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(questId, QuestStatus.COMPLETE, 2));
   return true;
 }
Пример #21
0
 private int getStoneId(Player player) {
   switch (player.getCommonData().getPlayerClass()) {
     case GLADIATOR:
       {
         return 140000008; // Improved Stamina I
       }
     case TEMPLAR:
       {
         return 140000027; // Divine Fury I
       }
     case RANGER:
       {
         return 140000047; // Arrow Deluge I
       }
     case ASSASSIN:
       {
         return 140000076; // Sigil Strike I
       }
     case SORCERER:
       {
         return 140000131; // Lumiel's Wisdom I
       }
     case SPIRIT_MASTER:
       {
         return 140000147; // Absorb Vitality I
       }
     case CLERIC:
       {
         return 140000098; // Grace of Empyrean Lord I
       }
     case CHANTER:
       {
         return 140000112; // Rage Spell I
       }
     case BARD:
       {
         return 140000859;
       }
     case GUNNER:
       {
         return 140000943;
       }
     default:
       {
         return 0;
       }
   }
 }
Пример #22
0
 @Override
 public boolean onEnterWorldEvent(QuestEnv env) {
   Player player = env.getPlayer();
   if (player.getCommonData().getRace() != Race.ASMODIANS) return false;
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null) {
     env.setQuestId(questId);
     QuestService.startQuest(env);
   }
   qs = player.getQuestStateList().getQuestState(questId);
   if (qs.getStatus() == QuestStatus.START) {
     PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(1, 2));
     return true;
   }
   return false;
 }
 @Override
 public boolean onEnterWorldEvent(QuestEnv env) {
   Player player = env.getPlayer();
   if (player.getWorldId() == 400010000) {
     PlayerClass playerClass = player.getCommonData().getPlayerClass();
     if (playerClass == PlayerClass.RIDER) {
       return false;
     }
     QuestState qs = player.getQuestStateList().getQuestState(questId);
     if (qs == null) {
       env.setQuestId(questId);
       if (QuestService.startQuest(env)) {
         return true;
       }
     }
   }
   return false;
 }
  /**
   * @param player
   * @param target
   * @return AP reward
   */
  public static int calculatePvEApGained(Player player, Creature target) {
    float apPercentage =
        target instanceof SiegeNpc
            ? 100f
            : APRewardEnum.apReward(player.getAbyssRank().getRank().getId());
    boolean lvlDiff = player.getCommonData().getLevel() - target.getLevel() > 10;
    float apNpcRate = ApNpcRating(((Npc) target).getObjectTemplate().getRating());

    // TODO: findout why they give 1/4 AP base(normal NpcRate) (5 AP retail)
    if (target.getName().equals("flame hoverstone")) {
      apNpcRate = 0.5f;
    }

    if (target.getName().equals("controllera") || target.getName().equals("controllerb")) {
      apNpcRate = 0f;
    }

    return (int)
        (lvlDiff
            ? 1
            : RewardType.AP_NPC.calcReward(
                player, (int) Math.floor(15 * apPercentage * apNpcRate / 100)));
  }
Пример #25
0
  public void rewardPlayer(Player player) {
    if (player != null) {
      int skillLvl = getObjectTemplate().getSkillLevel();
      int xpReward =
          (int)
              ((0.008 * (skillLvl + 100) * (skillLvl + 100) + 60)
                  * player.getRates().getGatheringXPRate());

      if (player
          .getSkillList()
          .addSkillXp(player, getObjectTemplate().getHarvestSkill(), xpReward)) {
        PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.EXTRACT_GATHER_SUCCESS_GETEXP());
        player.getCommonData().addExp(xpReward);
      } else
        PacketSendUtility.sendPacket(
            player,
            SM_SYSTEM_MESSAGE.MSG_DONT_GET_PRODUCTION_EXP(
                new DescriptionId(
                    DataManager.SKILL_DATA
                        .getSkillTemplate(getObjectTemplate().getHarvestSkill())
                        .getNameId())));
    }
  }
  /** @param player */
  public static void onPlayerLogin(Player player) {
    int worldId = player.getWorldId();

    WorldMapTemplate worldTemplate = DataManager.WORLD_MAPS_DATA.getTemplate(worldId);
    if (worldTemplate.isInstance()) {
      PortalTemplate portalTemplate =
          DataManager.PORTAL_DATA.getInstancePortalTemplate(
              worldId, player.getCommonData().getRace());

      if (portalTemplate == null) {
        log.error("No portal template found for " + worldId);
        return;
      }

      int lookupId = player.getObjectId();
      if (portalTemplate.isGroup() && player.getPlayerGroup() != null) {
        lookupId = player.getPlayerGroup().getGroupId();
      }

      WorldMapInstance registeredInstance = getRegisteredInstance(worldId, lookupId);
      if (registeredInstance != null) {
        World.getInstance()
            .setPosition(
                player,
                worldId,
                registeredInstance.getInstanceId(),
                player.getX(),
                player.getY(),
                player.getZ(),
                player.getHeading());
        return;
      }

      moveToEntryPoint(player, portalTemplate, false);
    }
  }
Пример #27
0
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    final int instanceId = player.getInstanceId();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

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

    if (qs.getStatus() == QuestStatus.START) {
      if (targetId == 790001) {
        switch (env.getDialogId()) {
          case 25:
            if (var == 0)
              return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
            else if (var == 3)
              return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1693);
            else if (var == 5)
              return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2034);
          case 10000:
            if (var == 0) {
              if (player.getInventory().getItemCountByItemId(182200007) == 0)
                if (!itemService.addItems(
                    player, Collections.singletonList(new QuestItems(182200007, 1)))) return true;
              qs.setQuestVarById(0, var + 1);
              updateQuestStatus(player, qs);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return true;
            }
          case 10002:
            if (var == 3) {
              player.getInventory().removeFromBagByItemId(182200009, 1);
              qs.setQuestVar(99);
              updateQuestStatus(player, qs);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0));
              WorldMapInstance newInstance = instanceService.getNextAvailableInstance(310010000);
              instanceService.registerPlayerWithInstance(newInstance, player);
              teleportService.teleportTo(
                  player, 310010000, newInstance.getInstanceId(), 52, 174, 229, 0);
              return true;
            }
          case 10003:
            if (var == 5) {
              PlayerClass playerClass = player.getCommonData().getPlayerClass();
              if (playerClass == PlayerClass.WARRIOR)
                return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
              else if (playerClass == PlayerClass.SCOUT)
                return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2716);
              else if (playerClass == PlayerClass.MAGE)
                return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 3057);
              else if (playerClass == PlayerClass.PRIEST)
                return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 3398);
            }
          case 10004:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.GLADIATOR);
          case 10005:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.TEMPLAR);
          case 10006:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.ASSASSIN);
          case 10007:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.RANGER);
          case 10008:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.SORCERER);
          case 10009:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.SPIRIT_MASTER);
          case 10010:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.CLERIC);
          case 10011:
            if (var == 5) return setPlayerClass(env, qs, PlayerClass.CHANTER);
        }
      } else if (targetId == 730008) {
        switch (env.getDialogId()) {
          case 25:
            if (var == 2) {
              if (player.getInventory().getItemCountByItemId(182200008) != 0)
                return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
              else return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1354);
            }
          case 1353:
            if (var == 2) {
              PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 14));
              player.getInventory().removeFromBagByItemId(182200008, 1);
              itemService.addItems(player, Collections.singletonList(new QuestItems(182200009, 1)));
            }
            return false;
          case 10001:
            if (var == 2) {
              qs.setQuestVarById(0, var + 1);
              updateQuestStatus(player, qs);
              PacketSendUtility.sendPacket(
                  player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
              return true;
            }
        }
      } else if (targetId == 205000) {
        switch (env.getDialogId()) {
          case 25:
            if (var == 99) {
              PacketSendUtility.sendPacket(player, new SM_EMOTION(player, 6, 1001, 0));
              qs.setQuestVar(50);
              updateQuestStatus(player, qs);
              ThreadPoolManager.getInstance()
                  .schedule(
                      new Runnable() {
                        @Override
                        public void run() {
                          qs.setQuestVar(51);
                          updateQuestStatus(player, qs);
                          List<Npc> mobs = new ArrayList<Npc>();
                          mobs.add(
                              (Npc)
                                  questService.addNewSpawn(
                                      310010000,
                                      instanceId,
                                      211042,
                                      (float) 224.073,
                                      (float) 239.1,
                                      (float) 206.7,
                                      (byte) 0,
                                      true));
                          mobs.add(
                              (Npc)
                                  questService.addNewSpawn(
                                      310010000,
                                      instanceId,
                                      211042,
                                      (float) 233.5,
                                      (float) 241.04,
                                      (float) 206.365,
                                      (byte) 0,
                                      true));
                          mobs.add(
                              (Npc)
                                  questService.addNewSpawn(
                                      310010000,
                                      instanceId,
                                      211042,
                                      (float) 229.6,
                                      (float) 265.7,
                                      (float) 205.7,
                                      (byte) 0,
                                      true));
                          mobs.add(
                              (Npc)
                                  questService.addNewSpawn(
                                      310010000,
                                      instanceId,
                                      211042,
                                      (float) 222.8,
                                      (float) 262.5,
                                      (float) 205.7,
                                      (byte) 0,
                                      true));
                          for (Npc mob : mobs) {
                            // TODO: Tempt decrease P attack.
                            mob.getGameStats()
                                .setStat(
                                    StatEnum.MAIN_HAND_POWER,
                                    mob.getGameStats().getCurrentStat(StatEnum.MAIN_HAND_POWER)
                                        / 3);
                            mob.getGameStats().setStat(StatEnum.PHYSICAL_DEFENSE, 0);
                            mob.getAggroList().addDamage(player, 1000);
                          }
                        }
                      },
                      43000);
              return true;
            }
            return false;
          default:
            return false;
        }
      }
    } else if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 790001) {
        return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
Пример #28
0
  /**
   * Returns the player with given objId (if such player exists)
   *
   * @param playerObjId
   * @param account
   * @return Player
   */
  public static Player getPlayer(int playerObjId, Account account) {
    Player player = playerCache.get(playerObjId);
    if (player != null) return player;

    /** Player common data and appearance should be already loaded in account */
    PlayerAccountData playerAccountData = account.getPlayerAccountData(playerObjId);
    PlayerCommonData pcd = playerAccountData.getPlayerCommonData();
    PlayerAppearance appearance = playerAccountData.getAppereance();

    player = new Player(new PlayerController(), pcd, appearance);

    LegionMember legionMember = LegionService.getInstance().getLegionMember(player.getObjectId());
    if (legionMember != null) player.setLegionMember(legionMember);

    if (GroupService.getInstance().isGroupMember(playerObjId))
      GroupService.getInstance().setGroup(player);

    if (AllianceService.getInstance().isAllianceMember(playerObjId))
      AllianceService.getInstance().setAlliance(player);

    MacroList macroses = DAOManager.getDAO(PlayerMacrossesDAO.class).restoreMacrosses(playerObjId);
    player.setMacroList(macroses);

    player.setSkillList(DAOManager.getDAO(PlayerSkillListDAO.class).loadSkillList(playerObjId));
    player.setKnownlist(new KnownList(player));
    player.setFriendList(DAOManager.getDAO(FriendListDAO.class).load(player));
    player.setBlockList(DAOManager.getDAO(BlockListDAO.class).load(player));
    player.setTitleList(DAOManager.getDAO(PlayerTitleListDAO.class).loadTitleList(playerObjId));

    DAOManager.getDAO(PlayerSettingsDAO.class).loadSettings(player);
    DAOManager.getDAO(AbyssRankDAO.class).loadAbyssRank(player);
    PlayerStatsData playerStatsData = DataManager.PLAYER_STATS_DATA;
    player.setPlayerStatsTemplate(playerStatsData.getTemplate(player));

    player.setGameStats(new PlayerGameStats(playerStatsData, player));

    Equipment equipment = DAOManager.getDAO(InventoryDAO.class).loadEquipment(player);
    ItemService.loadItemStones(equipment.getEquippedItemsWithoutStigma());
    equipment.setOwner(player);
    player.setEquipment(equipment);

    player.setLifeStats(new PlayerLifeStats(player));
    player.setEffectController(new PlayerEffectController(player));
    player.setFlyController(new FlyController(player));
    player.setReviveController(new ReviveController(player));

    player.setQuestStateList(DAOManager.getDAO(PlayerQuestListDAO.class).load(player));
    player.setRecipeList(DAOManager.getDAO(PlayerRecipesDAO.class).load(player.getObjectId()));

    /** Account warehouse should be already loaded in account */
    Storage accWarehouse = account.getAccountWarehouse();

    player.setStorage(accWarehouse, StorageType.ACCOUNT_WAREHOUSE);

    Storage inventory =
        DAOManager.getDAO(InventoryDAO.class)
            .loadStorage(player, player.getObjectId(), StorageType.CUBE);
    ItemService.loadItemStones(inventory.getStorageItems());

    player.setStorage(inventory, StorageType.CUBE);

    Storage warehouse =
        DAOManager.getDAO(InventoryDAO.class)
            .loadStorage(player, player.getObjectId(), StorageType.REGULAR_WAREHOUSE);
    ItemService.loadItemStones(warehouse.getStorageItems());

    player.setStorage(warehouse, StorageType.REGULAR_WAREHOUSE);

    /** Apply equipment stats (items and manastones were loaded in account) */
    player.getEquipment().onLoadApplyEquipmentStats();

    DAOManager.getDAO(PlayerPunishmentsDAO.class).loadPlayerPunishments(player);

    ItemService.restoreKinah(player);

    // update passive stats after effect controller, stats and equipment are initialized
    player.getController().updatePassiveStats();
    // load saved effects
    DAOManager.getDAO(PlayerEffectsDAO.class).loadPlayerEffects(player);
    // load item cooldowns
    DAOManager.getDAO(ItemCooldownsDAO.class).loadItemCooldowns(player);

    if (player.getCommonData().getTitleId() > 0) {
      TitleChangeListener.onTitleChange(
          player.getGameStats(), player.getCommonData().getTitleId(), true);
    }
    player.getGameStats().recomputeStats();

    DAOManager.getDAO(PlayerLifeStatsDAO.class).loadPlayerLifeStat(player);
    // analyze current instance
    InstanceService.onPlayerLogin(player);

    if (CacheConfig.CACHE_PLAYERS) playerCache.put(playerObjId, player);

    return player;
  }
Пример #29
0
  public void executeCommand(Player admin, String[] params) {
    if (params == null || params.length < 1) {
      PacketSendUtility.sendMessage(admin, "syntax //bind < all | elyos | asmos >");
      return;
    }

    if (params[0].equals("all")) {
      if (admin.getAccessLevel() < AdminConfig.COMMAND_MOVETOMEALLALL) {
        PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
        return;
      }

      World world = admin.getActiveRegion().getWorld();
      Iterator<Player> players = world.getPlayersIterator();
      while (players.hasNext()) {
        Player p = players.next();
        if (!p.equals(admin)) {
          teleportService.teleportTo(
              p,
              admin.getWorldId(),
              admin.getInstanceId(),
              admin.getX(),
              admin.getY(),
              admin.getZ(),
              admin.getHeading(),
              5);
          PacketSendUtility.sendPacket(p, new SM_PLAYER_SPAWN(p));

          PacketSendUtility.sendMessage(admin, "Player " + p.getName() + " teleported.");
          PacketSendUtility.sendMessage(p, "Vous avez ete teleporte par " + admin.getName() + ".");
        }
      }
    }

    if (params[0].equals("elyos")) {
      if (admin.getAccessLevel() < AdminConfig.COMMAND_MOVETOMEALLELYOS) {
        PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
        return;
      }

      World world = admin.getActiveRegion().getWorld();
      Iterator<Player> players = world.getPlayersIterator();
      while (players.hasNext()) {
        Player p = players.next();
        if (!p.equals(admin)) {
          if (p.getCommonData().getRace() == Race.ELYOS) {
            teleportService.teleportTo(
                p,
                admin.getWorldId(),
                admin.getInstanceId(),
                admin.getX(),
                admin.getY(),
                admin.getZ(),
                admin.getHeading(),
                5);
            PacketSendUtility.sendPacket(p, new SM_PLAYER_SPAWN(p));

            PacketSendUtility.sendMessage(admin, "Player " + p.getName() + " teleported.");
            PacketSendUtility.sendMessage(
                p, "Vous avez ete teleporte par " + admin.getName() + ".");
          }
        }
      }
    }

    if (params[0].equals("asmos")) {
      if (admin.getAccessLevel() < AdminConfig.COMMAND_MOVETOMEALLASMOS) {
        PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
        return;
      }

      World world = admin.getActiveRegion().getWorld();
      Iterator<Player> players = world.getPlayersIterator();
      while (players.hasNext()) {
        Player p = players.next();
        if (!p.equals(admin)) {
          if (p.getCommonData().getRace() == Race.ASMODIANS) {
            teleportService.teleportTo(
                p,
                admin.getWorldId(),
                admin.getInstanceId(),
                admin.getX(),
                admin.getY(),
                admin.getZ(),
                admin.getHeading(),
                5);
            PacketSendUtility.sendPacket(p, new SM_PLAYER_SPAWN(p));

            PacketSendUtility.sendMessage(admin, "Player " + p.getName() + " teleported.");
            PacketSendUtility.sendMessage(
                p, "Vous avez ete teleporte par " + admin.getName() + ".");
          }
        }
      }
    }
  }