Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
 @Override
 public boolean onQuestTimerEndEvent(QuestEnv env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null && qs.getStatus() == QuestStatus.START) {
     removeQuestItem(env, 182204426, 1);
     QuestService.abandonQuest(player, questId);
     player.getController().updateNearbyQuests();
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
  @Override
  public void execute(Player admin, String... params) {
    if (params == null || params.length < 1) {
      PacketSendUtility.sendMessage(admin, "Syntax: //ungag <player>");
      return;
    }

    String name = Util.convertName(params[0]);
    Player player = World.getInstance().findPlayer(name);
    if (player == null) {
      PacketSendUtility.sendMessage(admin, "Player " + name + " was not found!");
      PacketSendUtility.sendMessage(admin, "Syntax: //ungag <player>");
      return;
    }

    player.setGagged(false);
    Future<?> task = player.getController().getTask(TaskId.GAG);
    if (task != null) player.getController().cancelTask(TaskId.GAG);
    PacketSendUtility.sendMessage(player, "You have been ungagged");

    PacketSendUtility.sendMessage(admin, "Player " + name + " ungagged");
  }
Exemplo n.º 4
0
  @Override
  protected void runImpl() {

    final Player player = getConnection().getActivePlayer();
    boolean haveUnreadExpress =
        (player.getMailbox().haveUnreadByType(LetterType.EXPRESS)
            || player.getMailbox().haveUnreadByType(LetterType.BLACKCLOUD));
    switch (this.action) {
      case 0:
        // window is closed
        if (player.getPostman() != null) {
          player.getPostman().getController().onDelete();
          player.setPostman(null);
        }
        break;
      case 1:
        // click on icon
        if (player.getPostman() != null) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_POSTMAN_ALREADY_SUMMONED);
        } else if (player.isFlying()) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_POSTMAN_UNABLE_IN_FLIGHT);
        } else if (player.getController().hasTask(TaskId.EXPRESS_MAIL_USE)) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_POSTMAN_UNABLE_IN_COOLTIME);
        } else if (haveUnreadExpress) {
          VisibleObjectSpawner.spawnPostman(player);
          Future<?> task =
              ThreadPoolManager.getInstance()
                  .schedule(
                      new Runnable() {
                        @Override
                        public void run() {}
                      },
                      600000); // 10 min
          player.getController().addTask(TaskId.EXPRESS_MAIL_USE, task);
        }
        break;
    }
  }
Exemplo n.º 5
0
  public static void playerLoggedOutDelay(final Player player, int delay) {
    // force stop movement of player
    player.getController().stopMoving();

    ThreadPoolManager.getInstance()
        .scheduleTaskManager(
            new Runnable() {
              @Override
              public void run() {
                playerLoggedOut(player);
              }
            },
            delay);
  }
  /**
   * 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, boolean stoped) {
    if (player.isInvul()) {
      return false;
    }

    if (distance >= FallDamageConfig.MAXIMUM_DISTANCE_DAMAGE || !stoped) {
      player.getController().onStopMove();
      player.getFlyController().onStopGliding(false);
      player.getLifeStats().reduceHp(player.getLifeStats().getMaxHp() + 1, player);
      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, 0, -damage));
    }

    return false;
  }
Exemplo n.º 7
0
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {

    Player activePlayer = getConnection().getActivePlayer();

    activePlayer.setLifeStats(
        new PlayerLifeStats(
            activePlayer,
            activePlayer.getPlayerStatsTemplate().getMaxHp(),
            activePlayer.getPlayerStatsTemplate().getMaxMp()));

    activePlayer.unsetState(CreatureState.DEAD);
    activePlayer.getController().startProtectionActiveTask();

    sendPacket(SM_SYSTEM_MESSAGE.REVIVE);
    // TODO: It is not always necessary.
    // sendPacket(new SM_QUEST_LIST(activePlayer));
    sendPacket(new SM_STATS_INFO(activePlayer));
    sendPacket(new SM_PLAYER_INFO(activePlayer, false));

    teleportService.moveToBindLocation(activePlayer, true);
  }
 @Override
 public void onEnterInstance(Player player) {
   if (isStartTimer) {
     long time = System.currentTimeMillis() - startTime;
     if (time < 900000) {
       PacketSendUtility.sendPacket(player, new SM_QUEST_ACTION(0, 900 - (int) time / 1000));
     }
   }
   player.getController().registerListener(this);
   entrance += 1;
   if (player.getRace() == Race.ELYOS) {
     PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 498));
     if (entrance == 1) {
       spawn(701646, 763.51685f, 533.11804f, 576.5853f, (byte) 59); // TANK ELYOS
       spawn(801763, 740.7189f, 536.31616f, 575.6878f, (byte) 1);
     }
   } else {
     PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 499));
     if (entrance == 1) {
       spawn(701647, 763.51685f, 533.11804f, 576.5853f, (byte) 59); // TANK ASMO
       spawn(801765, 740.7189f, 536.31616f, 575.6878f, (byte) 1);
     }
   }
 }
Exemplo n.º 9
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;
  }
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    AionConnection client = getConnection();
    Account account = client.getAccount();
    PlayerAccountData playerAccData = client.getAccount().getPlayerAccountData(objectId);

    if (playerAccData == null) {
      // Somebody wanted to login on character that is not at his account
      return;
    }

    Player player = PlayerService.getPlayer(objectId, account);

    if (player != null && client.setActivePlayer(player)) {
      player.setClientConnection(client);
      /*
       * Store player into World.
       */
      World.getInstance().storeObject(player);

      sendPacket(new SM_SKILL_LIST(player));
      StigmaService.onPlayerLogin(player);

      if (player.getSkillCoolDowns() != null)
        sendPacket(new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));

      if (player.getItemCoolDowns() != null)
        sendPacket(new SM_ITEM_COOLDOWN(player.getItemCoolDowns()));

      sendPacket(new SM_QUEST_LIST(player));
      sendPacket(new SM_RECIPE_LIST(player.getRecipeList().getRecipeList()));

      /*
       * Needed
       */
      sendPacket(new SM_ENTER_WORLD_CHECK());

      byte[] uiSettings = player.getPlayerSettings().getUiSettings();
      byte[] shortcuts = player.getPlayerSettings().getShortcuts();

      if (uiSettings != null) sendPacket(new SM_UI_SETTINGS(uiSettings, 0));

      if (shortcuts != null) sendPacket(new SM_UI_SETTINGS(shortcuts, 1));

      // Cubesize limit set in inventory.
      int cubeSize = player.getCubeSize();
      player.getInventory().setLimit(27 + cubeSize * 9);

      // items
      Storage inventory = player.getInventory();
      List<Item> equipedItems = player.getEquipment().getEquippedItems();
      if (equipedItems.size() != 0) {
        sendPacket(new SM_INVENTORY_INFO(player.getEquipment().getEquippedItems(), cubeSize));
      }

      List<Item> unequipedItems = inventory.getAllItems();
      int itemsSize = unequipedItems.size();

      if (itemsSize != 0) {
        int index = 0;
        while (index + 10 < itemsSize) {
          sendPacket(new SM_INVENTORY_INFO(unequipedItems.subList(index, index + 10), cubeSize));
          index += 10;
        }
        sendPacket(new SM_INVENTORY_INFO(unequipedItems.subList(index, itemsSize), cubeSize));
      }

      sendPacket(new SM_INVENTORY_INFO());

      PlayerService.playerLoggedIn(player);

      sendPacket(new SM_STATS_INFO(player));
      sendPacket(new SM_CUBE_UPDATE(player, 6));

      KiskService.onLogin(player);
      TeleportService.sendSetBindPoint(player);

      sendPacket(new SM_MACRO_LIST(player));
      sendPacket(new SM_GAME_TIME());
      player.getController().updateNearbyQuests();

      sendPacket(new SM_TITLE_LIST(player));
      sendPacket(new SM_CHANNEL_INFO(player.getPosition()));
      sendPacket(new SM_PLAYER_SPAWN(player));
      sendPacket(new SM_EMOTION_LIST());
      sendPacket(new SM_INFLUENCE_RATIO());
      sendPacket(new SM_PRICES(player.getPrices()));
      sendPacket(new SM_PLAYER_ID(player));
      sendPacket(new SM_ABYSS_RANK(player.getAbyssRank()));

      sendPacket(
          new SM_MESSAGE(
              0,
              null,
              "Welcome to "
                  + GSConfig.SERVER_NAME
                  + " server\nPowered by aion-unique software\ndeveloped by www.aion-unique.org team.\nCopyright 2010",
              ChatType.ANNOUNCEMENTS));

      if (player.isInPrison()) PunishmentService.updatePrisonStatus(player);

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

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

      player.setRates(Rates.getRatesFor(client.getAccount().getMembership()));

      ClassChangeService.showClassChangeDialog(player);

      /** Notify mail service to load all mails */
      MailService.getInstance().onPlayerLogin(player);
      /** Schedule periodic saving of this player */
      PeriodicSaveService.getInstance().onPlayerLogin(player);
      /** Notify player if have broker settled items */
      BrokerService.getInstance().onPlayerLogin(player);
      /** Start initializing chat connection(/1, /2, /3, /4 channels) */
      if (!GSConfig.DISABLE_CHAT_SERVER) ChatService.onPlayerLogin(player);
    } else {
      // TODO this is an client error - inform client.
    }
  }
 @Override
 public void onExitInstance(Player player) {
   super.onExitInstance(player);
   player.getController().unregisterListener();
 }
Exemplo n.º 12
0
  /** Apply effects and perform actions specified in skill template */
  protected void endCast() {
    if (!effector.isCasting() || isCancelled) return;

    // if target out of range
    if (skillTemplate == null) return;

    // Check if target is out of skill range
    Properties properties = skillTemplate.getProperties();
    if (properties != null && !properties.endCastValidate(this)) {
      effector.getController().cancelCurrentSkill();
      return;
    }

    if (!validateEffectedList()) {
      effector.getController().cancelCurrentSkill();
      return;
    }

    if (!preUsageCheck()) {
      return;
    }

    effector.setCasting(null);

    if (this.getSkillTemplate().isDeityAvatar() && effector instanceof Player) {
      AbyssService.rankerSkillAnnounce((Player) effector, this.getSkillTemplate().getNameId());
    }

    /** try removing item, if its not possible return to prevent exploits */
    if (effector instanceof Player && skillMethod == SkillMethod.ITEM) {
      Item item = ((Player) effector).getInventory().getItemByObjId(this.itemObjectId);
      if (item == null) return;
      if (item.getActivationCount() > 1) {
        item.setActivationCount(item.getActivationCount() - 1);
      } else {
        if (!((Player) effector)
            .getInventory()
            .decreaseByObjectId(item.getObjectId(), 1, ItemUpdateType.DEC_USE)) return;
      }
    }
    /** Create effects and precalculate result */
    int spellStatus = 0;
    int dashStatus = 0;
    int resistCount = 0;
    boolean blockedChain = false;
    boolean blockedStance = false;
    final List<Effect> effects = new ArrayList<Effect>();
    if (skillTemplate.getEffects() != null) {
      boolean blockAOESpread = false;
      for (Creature effected : effectedList) {
        Effect effect = new Effect(this, effected, 0, itemTemplate);
        if (effected instanceof Player) {
          if (effect.getEffectResult() == EffectResult.CONFLICT) blockedStance = true;
        }
        // Force RESIST status if AOE spell spread must be blocked
        if (blockAOESpread) effect.setAttackStatus(AttackStatus.RESIST);
        effect.initialize();
        final int worldId = effector.getWorldId();
        final int instanceId = effector.getInstanceId();
        effect.setWorldPosition(worldId, instanceId, x, y, z);

        effects.add(effect);
        spellStatus = effect.getSpellStatus().getId();
        dashStatus = effect.getDashStatus().getId();

        // Block AOE propagation if firstTarget resists the spell
        if ((!blockAOESpread)
            && (effect.getAttackStatus() == AttackStatus.RESIST)
            && (isTargetAOE())) blockAOESpread = true;

        if (effect.getAttackStatus() == AttackStatus.RESIST
            || effect.getAttackStatus() == AttackStatus.DODGE) {
          resistCount++;
        }
      }

      if (resistCount == effectedList.size()) {
        blockedChain = true;
        blockedPenaltySkill = true;
      }

      // exception for point point skills(example Ice Sheet)
      if (effectedList.isEmpty() && this.isPointPointSkill()) {
        Effect effect = new Effect(this, null, 0, itemTemplate);
        effect.initialize();
        final int worldId = effector.getWorldId();
        final int instanceId = effector.getInstanceId();
        effect.setWorldPosition(worldId, instanceId, x, y, z);
        effects.add(effect);
        spellStatus = effect.getSpellStatus().getId();
      }
    }

    if (effector instanceof Player && skillMethod == SkillMethod.CAST) {
      Player playerEffector = (Player) effector;
      if (playerEffector.getController().isUnderStance()) {
        playerEffector.getController().stopStance();
      }
      if (skillTemplate.isStance() && !blockedStance) {
        playerEffector.getController().startStance(skillTemplate.getSkillId());
      }
    }

    boolean setCooldowns = true;
    if (effector instanceof Player) {
      if (this.isMulticast()
          && ((Player) effector)
                  .getChainSkills()
                  .getChainCount((Player) effector, this.getSkillTemplate(), this.chainCategory)
              != 0) {
        setCooldowns = false;
      }
    }

    // Check Chain Skill Trigger Rate
    if (CustomConfig.SKILL_CHAIN_TRIGGERRATE) {
      int chainProb = skillTemplate.getChainSkillProb();
      if (this.chainCategory != null && !blockedChain) {
        this.chainSuccess = Rnd.get(90) < chainProb;
      }
    } else {
      this.chainSuccess = true;
    }

    /** set variables for chaincondition check */
    if (effector instanceof Player && this.chainSuccess && this.chainCategory != null) {
      ((Player) effector).getChainSkills().addChainSkill(this.chainCategory, this.isMulticast());
    }

    /** Perform necessary actions (use mp,dp items etc) */
    Actions skillActions = skillTemplate.getActions();
    if (skillActions != null) {
      for (Action action : skillActions.getActions()) {
        if (!action.act(this)) return;
      }
    }

    if (effector instanceof Player) {
      QuestEnv env = new QuestEnv(effector.getTarget(), (Player) effector, 0, 0);
      QuestEngine.getInstance().onUseSkill(env, skillTemplate.getSkillId());
    }

    if (setCooldowns) this.setCooldowns();

    if (hitTime == 0) applyEffect(effects);
    else {
      ThreadPoolManager.getInstance()
          .schedule(
              new Runnable() {

                @Override
                public void run() {
                  applyEffect(effects);
                }
              },
              hitTime);
    }
    if (skillMethod == SkillMethod.CAST
        || skillMethod == SkillMethod.ITEM
        || skillMethod == SkillMethod.CHARGE) sendCastspellEnd(spellStatus, dashStatus, effects);

    endCondCheck();

    if (effector instanceof Npc)
      SkillAttackManager.afterUseSkill((NpcAI2) ((Npc) effector).getAi2());
  }