コード例 #1
0
  private void adminModifyCharacter(L2PcInstance activeChar, String modifications) {
    L2Object target = activeChar.getTarget();

    if (!(target instanceof L2PcInstance)) return;

    L2PcInstance player = (L2PcInstance) target;
    StringTokenizer st = new StringTokenizer(modifications);

    if (st.countTokens() != 6) {
      editCharacter(player);
      return;
    }

    String hp = st.nextToken();
    String mp = st.nextToken();
    String cp = st.nextToken();
    String pvpflag = st.nextToken();
    String pvpkills = st.nextToken();
    String pkkills = st.nextToken();

    int hpval = Integer.parseInt(hp);
    int mpval = Integer.parseInt(mp);
    int cpval = Integer.parseInt(cp);
    int pvpflagval = Integer.parseInt(pvpflag);
    int pvpkillsval = Integer.parseInt(pvpkills);
    int pkkillsval = Integer.parseInt(pkkills);

    // Common character information
    L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[30]);
    cm.addNumber(hpval);
    cm.addNumber(mpval);
    cm.addNumber(cpval);
    cm.addNumber(pvpflagval);
    cm.addNumber(pvpkillsval);
    cm.addNumber(pkkillsval);
    cm.sendMessage(player);
    player.setCurrentHp(hpval);
    player.setCurrentMp(mpval);
    player.setCurrentCp(cpval);
    player.setPvpFlag(pvpflagval);
    player.setPvpKills(pvpkillsval);
    player.setPkKills(pkkillsval);

    // Save the changed parameters to the database.
    player.store();

    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_HP, hpval);
    su.addAttribute(StatusUpdate.MAX_HP, player.getMaxHp());
    su.addAttribute(StatusUpdate.CUR_MP, mpval);
    su.addAttribute(StatusUpdate.MAX_MP, player.getMaxMp());
    su.addAttribute(StatusUpdate.CUR_CP, cpval);
    su.addAttribute(StatusUpdate.MAX_CP, player.getMaxCp());
    player.sendPacket(su);

    // Admin information
    cm = new L2CoreMessage(MessageTable.Messages[70]);
    cm.addString(player.getName());
    cm.addNumber(hpval);
    cm.addNumber(mpval);
    cm.addNumber(cpval);
    cm.addNumber(pvpflagval);
    cm.addNumber(pvpkillsval);
    cm.addNumber(pkkillsval);
    cm.sendMessage(activeChar);

    if (Config.DEBUG)
      _log.fine(
          "[GM]"
              + activeChar.getName()
              + " changed stats of "
              + player.getName()
              + ". "
              + " HP: "
              + hpval
              + " MP: "
              + mpval
              + " CP: "
              + cpval
              + " PvP: "
              + pvpflagval
              + " / "
              + pvpkillsval);

    showCharacterInfo(activeChar, null); // Back to start

    player.broadcastPacket(new CharInfo(player));
    player.sendPacket(new UserInfo(player));
    player.broadcastPacket(new ExBrExtraUserInfo(player));
    player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
    player.decayMe();
    player.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  }
コード例 #2
0
ファイル: CursedWeapon.java プロジェクト: D3XV/D3X
  public void activate(L2PcInstance player, ItemInstance item) {
    // if the player is mounted, attempt to unmount first and pick it if successful.
    if (player.isMounted() && !player.dismount()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_PICKUP_S1)
              .addItemName(item.getItemId()));
      item.setDestroyProtected(true);
      player.dropItem("InvDrop", item, null, true);
      return;
    }

    _isActivated = true;

    // Hold player data.
    _player = player;
    _playerId = _player.getObjectId();
    _playerKarma = _player.getKarma();
    _playerPkKills = _player.getPkKills();

    _item = item;

    // Generate a random number for next stage.
    _numberBeforeNextStage =
        Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5));

    // Renew hungry time.
    _hungryTime = _durationLost * 60;

    // Activate the daily timer.
    _dailyTimerTask =
        ThreadPoolManager.getInstance()
            .scheduleGeneralAtFixedRate(new DailyTimerTask(), 60000L, 60000L);

    // Cancel the "1h dropped CW" timer.
    cancelDropTimerTask();

    insertData();

    // Change player stats
    _player.setCursedWeaponEquippedId(_itemId);
    _player.setKarma(9999999);
    _player.setPkKills(0);

    if (_player.isInParty()) _player.getParty().removePartyMember(_player, MessageType.Expelled);

    // Disable active toggles
    for (L2Effect effect : _player.getAllEffects()) {
      if (effect.getSkill().isToggle()) effect.exit();
    }

    // Add CW skills
    giveDemonicSkills();

    // Equip the weapon
    _player.useEquippableItem(_item, true);

    // Fully heal player
    _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
    _player.setCurrentCp(_player.getMaxCp());

    // Refresh player stats
    _player.broadcastUserInfo();

    // _player.broadcastPacket(new SocialAction(_player, 17));
    Broadcast.toAllOnlinePlayers(
        SystemMessage.getSystemMessage(
                SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
            .addZoneName(_player.getX(), _player.getY(), _player.getZ())
            .addItemName(_item.getItemId()));
  }