コード例 #1
0
ファイル: PetInfo.java プロジェクト: impos89/trunk
 public PetInfo(L2Summon summon, int val) {
   _summon = summon;
   _moveMultiplier = summon.getMovementSpeedMultiplier();
   _runSpd = (int) Math.round(summon.getRunSpeed() / _moveMultiplier);
   _walkSpd = (int) Math.round(summon.getWalkSpeed() / _moveMultiplier);
   _swimRunSpd = (int) Math.round(summon.getSwimRunSpeed() / _moveMultiplier);
   _swimWalkSpd = (int) Math.round(summon.getSwimWalkSpeed() / _moveMultiplier);
   _flyRunSpd = summon.isFlying() ? _runSpd : 0;
   _flyWalkSpd = summon.isFlying() ? _walkSpd : 0;
   _val = val;
   if (summon.isPet()) {
     final L2PetInstance pet = (L2PetInstance) _summon;
     _curFed = pet.getCurrentFed(); // how fed it is
     _maxFed = pet.getMaxFed(); // max fed it can be
   } else if (summon.isServitor()) {
     final L2ServitorInstance sum = (L2ServitorInstance) _summon;
     _curFed = sum.getLifeTimeRemaining();
     _maxFed = sum.getLifeTime();
   }
 }
コード例 #2
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if ("DESPAWN_GUARDIAN".equals(event)) {
      if (npc != null) {
        npc.deleteMe();
      }
      return super.onAdvEvent(event, npc, player);
    }

    final QuestState qs = getQuestState(player, false);
    String htmltext = null;
    if (qs == null) {
      return htmltext;
    }

    switch (event) {
      case "30610-05.htm":
        {
          if (qs.isCreated()) {
            if (getQuestItemsCount(
                    player, DRAGONFLUTE_OF_WIND, DRAGONFLUTE_OF_STAR, DRAGONFLUTE_OF_TWILIGHT)
                == 1) {
              final L2ItemInstance flute = getFlute(player);

              if (flute.getEnchantLevel() < MIN_HACHLING_LVL) {
                htmltext = "30610-06.html";
              } else {
                qs.startQuest();
                qs.setMemoState(100);
                qs.set("fluteObjectId", flute.getObjectId());
                htmltext = event;
              }
            } else {
              htmltext = "30610-06.html";
            }
          }
          break;
        }
      case "30747-04.html":
        {
          final L2Summon summon = player.getPet();

          if (summon == null) {
            htmltext = "30747-02.html";
          } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
            htmltext = "30747-03.html";
          } else {
            htmltext = event;
          }
          break;
        }
      case "30747-05.html":
        {
          final L2Summon summon = player.getPet();

          if (summon == null) {
            htmltext = "30747-06.html";
          } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
            htmltext = "30747-06.html";
          } else {
            giveItems(player, FAIRY_LEAF, 4);
            qs.setCond(2, true);
            qs.setMemoState(0);
            htmltext = event;
          }
          break;
        }
      case "30747-07.html":
      case "30747-08.html":
      case "30747-09.html":
      case "30747-10.html":
        {
          htmltext = event;
          break;
        }
    }
    return htmltext;
  }
コード例 #3
0
  @Override
  public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) {
    final QuestState qs = getQuestState(attacker, false);
    if ((qs != null) && qs.isCond(2)) {
      if (isSummon) {
        final NpcData data = NPC_DATA.get(npc.getId());
        if ((qs.getMemoState() % data.memoStateMod) < data.memoStateValue) {
          final L2Summon pet = attacker.getPet();
          if ((pet != null) && (pet.getControlObjectId() == qs.getInt("fluteObjectId"))) {
            final int hits = qs.getInt("hits") + 1;
            qs.set("hits", hits);

            if (hits < data.minHits) {
              if ((npc.getId() == TREE_OF_ABYSS) && (getRandom(100) < 2)) {
                npc.setTarget(attacker);
                npc.doCast(DRYAD_ROOT.getSkill());
              }
            } else if (getRandom(100) < 2) {
              if (hasQuestItems(attacker, FAIRY_LEAF)) {
                npc.broadcastPacket(
                    new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.GIVE_ME_A_FAIRY_LEAF));
                takeItems(attacker, FAIRY_LEAF, 1);
                qs.setMemoState(qs.getMemoState() + data.memoStateValue);
                qs.unset("hits");
                playSound(attacker, QuestSound.ITEMSOUND_QUEST_MIDDLE);

                if (qs.getMemoState() == 15) {
                  qs.setCond(3);
                }
              }
            }
          }
        } else {
          switch (getRandom(3)) {
            case 0:
              npc.broadcastPacket(
                  new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.WHY_DO_YOU_BOTHER_ME_AGAIN));
              break;
            case 1:
              npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, data.message));
              break;
            case 2:
              npc.broadcastPacket(
                  new NpcSay(
                      npc,
                      ChatType.NPC_GENERAL,
                      NpcStringId.LEAVE_NOW_BEFORE_YOU_INCUR_THE_WRATH_OF_THE_GUARDIAN_GHOST));
              break;
          }
        }
      } else if (getRandom(100) < 30) {
        npc.setTarget(attacker);
        npc.doCast(VICIOUS_POISON.getSkill());
      }
    } else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.67)) && (getRandom(100) < 30)) {
      npc.setTarget(attacker);
      npc.doCast(VICIOUS_POISON.getSkill());
    }

    return super.onAttack(npc, attacker, damage, isSummon);
  }
コード例 #4
0
  @Override
  public String onTalk(L2Npc npc, L2PcInstance talker) {
    final QuestState qs = getQuestState(talker, true);
    String htmltext = getNoQuestMsg(talker);

    switch (npc.getId()) {
      case CRONOS:
        {
          switch (qs.getState()) {
            case State.CREATED:
              {
                final long fluteCount =
                    getQuestItemsCount(
                        talker, DRAGONFLUTE_OF_WIND, DRAGONFLUTE_OF_STAR, DRAGONFLUTE_OF_TWILIGHT);
                if (fluteCount == 0) {
                  break; // this quest does not show up if no flute in inventory
                }

                if (talker.getLevel() < MIN_PLAYER_LVL) {
                  htmltext = "30610-01.htm";
                } else if (fluteCount > 1) {
                  htmltext = "30610-02.htm";
                } else if (getFlute(talker).getEnchantLevel() < MIN_HACHLING_LVL) {
                  htmltext = "30610-03.html";
                } else {
                  htmltext = "30610-04.htm";
                }
                break;
              }
            case State.STARTED:
              {
                htmltext = "30610-07.html";
                break;
              }
            case State.COMPLETED:
              {
                htmltext = getAlreadyCompletedMsg(talker);
                break;
              }
          }
          break;
        }
      case MIMYU:
        {
          switch (qs.getMemoState()) {
            case 100:
              {
                qs.setMemoState(200);
                htmltext = "30747-01.html";
                break;
              }
            case 200:
              {
                final L2Summon summon = talker.getPet();

                if (summon == null) {
                  htmltext = "30747-02.html";
                } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
                  htmltext = "30747-03.html";
                } else {
                  htmltext = "30747-04.html";
                }
                break;
              }
            case 0:
              {
                htmltext = "30747-07.html";
                break;
              }
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
              {
                if (hasQuestItems(talker, FAIRY_LEAF)) {
                  htmltext = "30747-11.html";
                }
                break;
              }
            case 15:
              {
                if (!hasQuestItems(talker, FAIRY_LEAF)) {
                  final L2Summon summon = talker.getPet();

                  if (summon == null) {
                    htmltext = "30747-12.html";
                  } else if (summon.getControlObjectId() == qs.getInt("fluteObjectId")) {
                    qs.setMemoState(16);
                    htmltext = "30747-13.html";
                  } else {
                    htmltext = "30747-14.html";
                  }
                }
                break;
              }
            case 16:
              {
                if (!hasQuestItems(talker, FAIRY_LEAF)) {
                  if (talker.hasSummon()) {
                    htmltext = "30747-15.html";
                  } else {
                    final long fluteCount =
                        getQuestItemsCount(
                            talker,
                            DRAGONFLUTE_OF_WIND,
                            DRAGONFLUTE_OF_STAR,
                            DRAGONFLUTE_OF_TWILIGHT);

                    if (fluteCount > 1) {
                      htmltext = "30747-17.html";
                    } else if (fluteCount == 1) {
                      final L2ItemInstance flute = getFlute(talker);

                      if (flute.getObjectId() == qs.getInt("fluteObjectId")) {
                        // TODO what if the hatchling has items in his inventory?
                        // Should they be transfered to the strider or given to the player?
                        switch (flute.getId()) {
                          case DRAGONFLUTE_OF_WIND:
                            takeItems(talker, DRAGONFLUTE_OF_WIND, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_WIND, 1);
                            break;
                          case DRAGONFLUTE_OF_STAR:
                            takeItems(talker, DRAGONFLUTE_OF_STAR, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_STAR, 1);
                            break;
                          case DRAGONFLUTE_OF_TWILIGHT:
                            takeItems(talker, DRAGONFLUTE_OF_TWILIGHT, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_TWILIGHT, 1);
                            break;
                        }

                        qs.exitQuest(true, true);
                        htmltext = "30747-16.html";
                      } else {
                        npc.setTarget(talker);
                        npc.doCast(CURSE_OF_MIMYU.getSkill());
                        htmltext = "30747-18.html";
                      }
                    }
                  }
                }
                break;
              }
          }
          break;
        }
    }
    return htmltext;
  }
コード例 #5
0
ファイル: PetInfo.java プロジェクト: impos89/trunk
  @Override
  protected final void writeImpl() {
    writeC(0xB2);
    writeC(_summon.getSummonType());
    writeD(_summon.getObjectId());
    writeD(_summon.getTemplate().getDisplayId() + 1000000);

    writeD(_summon.getX());
    writeD(_summon.getY());
    writeD(_summon.getZ());
    writeD(_summon.getHeading());

    writeD(_summon.getStat().getMAtkSpd());
    writeD((int) _summon.getStat().getPAtkSpd());

    writeH(_runSpd);
    writeH(_walkSpd);
    writeH(_swimRunSpd);
    writeH(_swimWalkSpd);
    writeH(_flRunSpd);
    writeH(_flWalkSpd);
    writeH(_flyRunSpd);
    writeH(_flyWalkSpd);

    writeF(_moveMultiplier);
    writeF(_summon.getAttackSpeedMultiplier()); // attack speed multiplier
    writeF(_summon.getTemplate().getfCollisionRadius());
    writeF(_summon.getTemplate().getfCollisionHeight());

    writeD(_summon.getWeapon()); // right hand weapon
    writeD(_summon.getArmor()); // body armor
    writeD(0x00); // left hand weapon

    writeC(_summon.isShowSummonAnimation() ? 0x02 : _val); // 0=teleported 1=default 2=summoned
    writeD(-1); // High Five NPCString ID
    if (_summon.isPet()) {
      writeS(_summon.getName()); // Pet name.
    } else {
      writeS(
          _summon.getTemplate().isUsingServerSideName() ? _summon.getName() : ""); // Summon name.
    }
    writeD(-1); // High Five NPCString ID
    writeS(_summon.getTitle()); // owner name

    writeC(_summon.getPvpFlag()); // confirmed
    writeD(_summon.getReputation()); // confirmed

    writeD(_curFed); // how fed it is
    writeD(_maxFed); // max fed it can be
    writeD((int) _summon.getCurrentHp()); // current hp
    writeD(_summon.getMaxHp()); // max hp
    writeD((int) _summon.getCurrentMp()); // current mp
    writeD(_summon.getMaxMp()); // max mp

    writeQ(_summon.getStat().getSp()); // sp
    writeC(_summon.getLevel()); // lvl
    writeQ(_summon.getStat().getExp());

    if (_summon.getExpForThisLevel() > _summon.getStat().getExp()) {
      writeQ(_summon.getStat().getExp()); // 0% absolute value
    } else {
      writeQ(_summon.getExpForThisLevel()); // 0% absolute value
    }

    writeQ(_summon.getExpForNextLevel()); // 100% absoulte value

    writeD(_summon.isPet() ? _summon.getInventory().getTotalWeight() : 0); // weight
    writeD(_summon.getMaxLoad()); // max weight it can carry
    writeD((int) _summon.getPAtk(null)); // patk
    writeD((int) _summon.getPDef(null)); // pdef
    writeD(_summon.getAccuracy()); // accuracy
    writeD(_summon.getEvasionRate(null)); // evasion
    writeD(_summon.getCriticalHit(null, null)); // critical
    writeD((int) _summon.getMAtk(null, null)); // matk
    writeD((int) _summon.getMDef(null, null)); // mdef
    writeD(_summon.getMagicAccuracy()); // magic accuracy
    writeD(_summon.getMagicEvasionRate(null)); // magic evasion
    writeD(_summon.getMCriticalHit(null, null)); // mcritical
    writeD((int) _summon.getStat().getMoveSpeed()); // speed
    writeD((int) _summon.getPAtkSpd()); // atkspeed
    writeD(_summon.getMAtkSpd()); // casting speed

    writeC(0); // TODO: Check me, might be ride status
    writeC(_summon.getTeam().getId()); // Confirmed
    writeC(
        _summon.getSoulShotsPerHit()); // How many soulshots this servitor uses per hit - Confirmed
    writeC(
        _summon
            .getSpiritShotsPerHit()); // How many spiritshots this servitor uses per hit - -
                                      // Confirmed

    writeD(0x00); // TODO: Find me
    writeD(_summon.getFormId()); // Transformation ID - Confirmed

    writeC(_summon.getOwner().getUsedSummonPoints()); // Used Summon Points
    writeC(_summon.getOwner().getMaxSummonPoints()); // Maximum Summon Points

    final Set<AbnormalVisualEffect> aves = _summon.getCurrentAbnormalVisualEffects();
    writeH(aves.size()); // Confirmed
    for (AbnormalVisualEffect ave : aves) {
      writeH(ave.getClientId()); // Confirmed
    }

    writeC(_summon.isMountable() ? 0x26 : 0x06); // c2 ride button
  }