Пример #1
0
  @Override
  protected void thinkActive() {
    Player actor = getActor();
    // FPCInfo player	= FPCInfo.getInstance(actor);

    if (actor.isActionsDisabled()) {
      return;
    }

    if (_def_think) {
      if (doTask()) {
        clearTasks();
      }
      return;
    }

    // player.cancelShop();

    if (Rnd.chance(0.5)) {
      actor.standUp();
      if (Rnd.chance(20)) randomWalk(1000);
      else {
        List<GameObject> chars = World.getAroundObjects(actor, 2000, 500);
        if (chars.size() == 0) return;
        GameObject randomChar = chars.get(Rnd.get(chars.size()));
        if (!randomChar.isDoor()) actor.moveToLocation(randomChar.getLoc(), 50, true);
      }
    }
  }
Пример #2
0
  @Override
  protected boolean thinkActive() {

    NpcInstance actor = getActor();

    int[][] coords;
    coords = SMP_COORDS;

    actor.setRunning();

    if (actor.getTarget() == null || currentState >= coords.length || currentState == 0) {
      if (currentState < coords.length) {
        actor.moveToLocation(
            coords[currentState][0],
            coords[currentState][1],
            coords[currentState][2],
            Rnd.get(0, 50),
            true);
        if (actor.getDestination() == null) {
          ++currentState;
        }
      } else {
        actor.doDie(actor);
      }
    }
    if (lastSayTimer + SAY_RAFF < System.currentTimeMillis()) {
      lastSayTimer = System.currentTimeMillis();
      Functions.npcSay(actor, NpcString.ITS_HERE, ChatType.NPC_ALL, 800);
    }

    return true;
  }
  @Override
  public String onEvent(String event, QuestState st, NpcInstance npc) {
    int _state = st.getState();
    int cond = st.getCond();
    if (event.equalsIgnoreCase("jeremy_q0625_0104.htm") && _state == CREATED) {
      if (st.getQuestItemsCount(Soy_Sauce_Jar) == 0) {
        st.exitCurrentQuest(true);
        return "jeremy_q0625_0102.htm";
      }
      st.setState(STARTED);
      st.setCond(1);
      st.takeItems(Soy_Sauce_Jar, 1);
      st.giveItems(Food_for_Bumbalump, 1);
      st.playSound(SOUND_ACCEPT);
    } else if (event.equalsIgnoreCase("jeremy_q0625_0301.htm") && _state == STARTED && cond == 3) {
      st.exitCurrentQuest(true);
      if (st.getQuestItemsCount(Special_Yeti_Meat) == 0) return "jeremy_q0625_0302.htm";
      st.takeItems(Special_Yeti_Meat, 1);
      st.giveItems(Rnd.get(Reward_First, Reward_Last), 5, true);
    } else if (event.equalsIgnoreCase("yetis_table_q0625_0201.htm")
        && _state == STARTED
        && cond == 1) {
      if (ServerVariables.getLong(_625_TheFinestIngredientsPart2.class.getSimpleName(), 0)
              + 3 * 60 * 60 * 1000
          > System.currentTimeMillis()) return "yetis_table_q0625_0204.htm";
      if (st.getQuestItemsCount(Food_for_Bumbalump) == 0) return "yetis_table_q0625_0203.htm";
      if (BumbalumpSpawned()) return "yetis_table_q0625_0202.htm";
      st.takeItems(Food_for_Bumbalump, 1);
      st.setCond(2);
      ThreadPoolManager.getInstance().schedule(new BumbalumpSpawner(), 1000);
    }

    return event;
  }
  @Override
  public String onKill(NpcInstance npc, QuestState st) {
    int npcId = npc.getNpcId();
    int cond = st.getCond();

    if (cond == 3 && ArrayUtils.contains(MOBS_1, npcId) && Rnd.chance(70)) {
      st.giveItems(ELCARDIAS_MARK, 1);
      if (st.getQuestItemsCount(ELCARDIAS_MARK) < 10) st.playSound(SOUND_ITEMGET);
      else {
        st.playSound(SOUND_MIDDLE);
        st.setCond(4);
      }
    } else if (npcId == CREATURE_OF_THE_DUSK_1) {
      st.set("CreatureOfTheDusk1", 2);
      if (st.get("CreatureOfTheDusk2") != null
          && Integer.parseInt(st.get("CreatureOfTheDusk2")) == 2) {
        st.playSound(SOUND_MIDDLE);
        st.setCond(6);
      }
    } else if (npcId == CREATURE_OF_THE_DUSK_2) {
      st.set("CreatureOfTheDusk2", 2);
      if (st.get("CreatureOfTheDusk1") != null
          && Integer.parseInt(st.get("CreatureOfTheDusk1")) == 2) {
        st.playSound(SOUND_MIDDLE);
        st.setCond(6);
      }
    }
    return null;
  }
Пример #5
0
  public static Location getRestartLocation(Player player, Location from, RestartType restartType) {
    Reflection r = player.getReflection();
    if (r != ReflectionManager.DEFAULT)
      if (r.getCoreLoc() != null) return r.getCoreLoc();
      else if (r.getReturnLoc() != null) return r.getReturnLoc();

    Clan clan = player.getClan();

    if (clan != null) {
      // If teleport to clan hall
      if (restartType == RestartType.TO_CLANHALL && clan.getHasHideout() != 0)
        return ResidenceHolder.getInstance()
            .getResidence(clan.getHasHideout())
            .getOwnerRestartPoint();

      // If teleport to castle
      if (restartType == RestartType.TO_CASTLE && clan.getCastle() != 0)
        return ResidenceHolder.getInstance().getResidence(clan.getCastle()).getOwnerRestartPoint();

      // If teleport to fortress
      if (restartType == RestartType.TO_FORTRESS && clan.getHasFortress() != 0)
        return ResidenceHolder.getInstance()
            .getResidence(clan.getHasFortress())
            .getOwnerRestartPoint();
    }

    if (player.isPK()) {
      if (player.getPKRestartPoint() != null) return player.getPKRestartPoint();
    } else {
      if (player.getRestartPoint() != null) return player.getRestartPoint();
    }

    RestartArea ra = MapRegionManager.getInstance().getRegionData(RestartArea.class, from);
    if (ra != null) {
      RestartPoint rp = ra.getRestartPoint().get(player.getRace());

      Location restartPoint = Rnd.get(rp.getRestartPoints());
      Location PKrestartPoint = Rnd.get(rp.getPKrestartPoints());

      return player.isPK() ? PKrestartPoint : restartPoint;
    }

    _log.warn("Cannot find restart location from coordinates: " + from + "!");

    return DEFAULT_RESTART;
  }
  public void start(Player player, int type, NpcInstance npc) {
    if (!player.isInParty()) {
      showHtmlFile(player, "rift/NoParty.htm", npc);
      return;
    }

    if (!player.isGM()) {
      if (!player.getParty().isLeader(player)) {
        showHtmlFile(player, "rift/NotPartyLeader.htm", npc);
        return;
      }

      if (player.getParty().isInDimensionalRift()) {
        showHtmlFile(player, "rift/Cheater.htm", npc);

        if (!player.isGM())
          _log.warn(
              "Player "
                  + player.getName()
                  + "("
                  + player.getObjectId()
                  + ") was cheating in dimension rift area!");

        return;
      }

      if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) {
        showHtmlFile(player, "rift/SmallParty.htm", npc);
        return;
      }

      for (Player p : player.getParty().getPartyMembers())
        if (!checkIfInPeaceZone(p.getLoc())) {
          showHtmlFile(player, "rift/NotInWaitingRoom.htm", npc);
          return;
        }

      ItemInstance i;
      for (Player p : player.getParty().getPartyMembers()) {
        i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID);
        if (i == null || i.getCount() < getNeededItems(type)) {
          showHtmlFile(player, "rift/NoFragments.htm", npc);
          return;
        }
      }

      for (Player p : player.getParty().getPartyMembers())
        if (!p.getInventory()
            .destroyItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID, getNeededItems(type))) {
          showHtmlFile(player, "rift/NoFragments.htm", npc);
          return;
        }
    }

    new DimensionalRift(player.getParty(), type, Rnd.get(1, _rooms.get(type).size() - 1));
  }
Пример #7
0
 @Override
 public void onDeath(Creature self, Creature killer) {
   if (self.isNpc()) {
     if (self.getNpcId() == HallAlarmDevice) {
       for (int i = 0; i < hallADoors.length; i++) openDoor(hallADoors[i]);
       blockUnblockNpcs(false, blockANpcs);
       for (NpcInstance n : getNpcs())
         if (ArrayUtils.contains(blockANpcs, n.getNpcId()))
           n.getAI()
               .notifyEvent(
                   CtrlEvent.EVT_AGGRESSION,
                   getPlayers().get(Rnd.get(getPlayers().size())),
                   200);
     } else if (ArrayUtils.contains(blockANpcs, self.getNpcId())) {
       // ToCheck: find easier way
       for (NpcInstance n : getNpcs())
         if (ArrayUtils.contains(blockANpcs, n.getNpcId()) && !n.isDead()) return;
       for (int i = 0; i < corridorADoors.length; i++) openDoor(corridorADoors[i]);
       blockUnblockNpcs(true, blockBNpcs);
     } else if (self.getNpcId() == DarkChoirPlayer) {
       for (NpcInstance n : getNpcs())
         if (n.getNpcId() == DarkChoirPlayer && !n.isDead()) return;
       for (int i = 0; i < hallBDoors.length; i++) openDoor(hallBDoors[i]);
       blockUnblockNpcs(false, blockBNpcs);
     } else if (ArrayUtils.contains(blockBNpcs, self.getNpcId())) {
       if (Rnd.chance(10)) ((NpcInstance) self).dropItem(killer.getPlayer(), DewdropItem, 1);
       // ToCheck: find easier way
       for (NpcInstance n : getNpcs())
         if ((ArrayUtils.contains(blockBNpcs, n.getNpcId())
                 || ArrayUtils.contains(blockANpcs, n.getNpcId()))
             && !n.isDead()) return;
       for (int i = 0; i < corridorBDoors.length; i++) openDoor(corridorBDoors[i]);
       ThreadPoolManager.getInstance().schedule(new FrintezzaStart(), battleStartDelay);
     } else if (self.getNpcId() == _weakScarletId) {
       self.decayMe();
       return;
     } else if (self.getNpcId() == _strongScarletId) {
       ThreadPoolManager.getInstance().schedule(new Die(1), 10);
       setReenterTime(System.currentTimeMillis());
     }
   }
 }
Пример #8
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    Player player;

    // follow the player
    double distance;

    if (targetPlayers != null && targetPlayers.size() > 0 && followTargetIndex > 0) {
      player = targetPlayers.get(followTargetIndex - 1);

      // in case the player set to follow is null, fall back to the first player in the list
      if (player == null) player = targetPlayers.get(0);

      distance = (int) actor.getDistance(player);

      if (distance > maxFollowDistance) {
        if (GeoEngine.canSeeTarget(actor, player, false)) {
          // in case the NPC can see the player
          actor.setRunning();
          Location loc =
              new Location(
                  player.getX() + Rnd.get(-60, 60),
                  player.getY() + Rnd.get(-60, 60),
                  player.getZ());
          actor.followToCharacter(loc, player, minFollowDistance, false);
        } else {
          // in case the NPC cannot see the player, then teleport straight to him
          actor.teleToLocation(player.getLoc().getRandomLoc(100));
        }
        return true;
      }
    }

    return startAttack();
  }
Пример #9
0
 /**
  * Checks if Frintezza's minions need heal (only major minions are checked) Return a "need heal"
  * = true only 40% of the time
  */
 private boolean minionsNeedHeal() {
   if (!Rnd.chance(40)) return false;
   if (weakScarlet != null
       && !weakScarlet.isAlikeDead()
       && weakScarlet.getCurrentHp() < weakScarlet.getMaxHp() * 2 / 3) return true;
   if (strongScarlet != null
       && !strongScarlet.isAlikeDead()
       && strongScarlet.getCurrentHp() < strongScarlet.getMaxHp() * 2 / 3) return true;
   for (int i = 0; i < 4; i++) {
     if (portraits[i] != null
         && !portraits[i].isDead()
         && portraits[i].getCurrentHp() < portraits[i].getMaxHp() / 3) return true;
     if (demons[i] != null
         && !demons[i].isDead()
         && demons[i].getCurrentHp() < demons[i].getMaxHp() / 3) return true;
   }
   return false;
 }
 public BumbalumpSpawner() {
   if (BumbalumpSpawned()) return;
   NpcTemplate template = NpcHolder.getInstance().getTemplate(RB_Icicle_Emperor_Bumbalump);
   if (template == null) return;
   try {
     _spawn = new SimpleSpawner(template);
   } catch (Exception E) {
     return;
   }
   _spawn.setLocx(158240);
   _spawn.setLocy(-121536);
   _spawn.setLocz(-2253);
   _spawn.setHeading(Rnd.get(0, 0xFFFF));
   _spawn.setAmount(1);
   _spawn.doSpawn(true);
   _spawn.stopRespawn();
   for (NpcInstance _npc : _spawn.getAllSpawned()) _npc.addListener(new DeathListener());
 }
Пример #11
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    if (actor.isDead()) return true;

    if (_def_think) {
      doTask();
      return true;
    }

    if (System.currentTimeMillis() > wait_timeout && (current_point > -1 || Rnd.chance(5))) {
      if (!wait)
        switch (current_point) {
          case 5:
            wait_timeout = System.currentTimeMillis() + 15000;
            Functions.npcSay(actor, "The Mother Tree is always so gorgeous!");
            wait = true;
            return true;
          case 9:
            wait_timeout = System.currentTimeMillis() + 60000;
            Functions.npcSay(actor, "Lady Mirabel, may the peace of the lake be with you!");
            wait = true;
            return true;
        }

      wait_timeout = 0;
      wait = false;
      current_point++;

      if (current_point >= points.length) current_point = 0;

      addTaskMove(points[current_point], true);
      doTask();
      return true;
    }

    if (randomAnimation()) return true;

    return false;
  }
Пример #12
0
 @Override
 public void runImpl() throws Exception {
   if (frintezza == null) return;
   int song = Math.max(1, Math.min(4, getSong()));
   NpcString song_name;
   switch (song) {
     case 1:
       song_name = NpcString.REQUIEM_OF_HATRED;
       break;
     case 2:
       song_name = NpcString.FRENETIC_TOCCATA;
       break;
     case 3:
       song_name = NpcString.FUGUE_OF_JUBILATION;
       break;
     case 4:
       song_name = NpcString.MOURNFUL_CHORALE_PRELUDE;
       break;
     default:
       return;
   }
   if (!frintezza.isBlocked()) {
     frintezza.broadcastPacket(
         new ExShowScreenMessage(
             song_name, 3000, ScreenMessageAlign.TOP_CENTER, true, 1, -1, true));
     frintezza.broadcastPacket(
         new MagicSkillUse(frintezza, frintezza, 5007, song, _intervalOfFrintezzaSongs, 0));
     // Launch the song's effects (they start about 10 seconds after he starts to play)
     ThreadPoolManager.getInstance()
         .schedule(new SongEffectLaunched(getSongTargets(song), song, 10000), 10000);
   }
   // Schedule a new song to be played in 30-40 seconds...
   musicTask =
       ThreadPoolManager.getInstance()
           .schedule(new Music(), _intervalOfFrintezzaSongs + Rnd.get(10000));
 }
Пример #13
0
 /**
  * returns the chosen symphony for Frintezza to play If the minions are injured he has 40% to
  * play a healing song If they are all dead, he will only play harmful player symphonies
  */
 private int getSong() {
   if (minionsNeedHeal()) return 1;
   return Rnd.get(2, 4);
 }
Пример #14
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    Creature target = actor.getFollowTarget();

    if (target == null || !(target instanceof Player)) {
      if (actor != null) actor.deleteMe();
      return false;
    }

    int npcId = actor.getNpcId();
    int[][] coords;
    NpcString string;
    NpcString end_String;
    // Select coords
    switch (npcId) {
      case SEARCHING_MYST_POWER_SOLDIER:
        coords = SMP_COORDS;
        string = SEARCHING_MYST_POWER_STRING;
        end_String = NpcString.S1_THAT_MAN_IN_FRONT_IS_IBANE;
        break;
      case BACKUP_SEEKERS_ASSASSIN:
        coords = BS_COORDS;
        string = BACKUP_SEEKERS_STRING;
        end_String = NpcString.TALK_TO_THAT_APPRENTICE_AND_GET_ON_KOOKARU;
        break;
      case GOING_INTO_REAL_WAR_SOLDIER:
        double distLeft =
            target.getDistance(GRW_COORDS_LEFT[0][0], GRW_COORDS_LEFT[0][1], GRW_COORDS_LEFT[0][2]);
        double distRight =
            target.getDistance(
                GRW_COORDS_RIGHT[0][0], GRW_COORDS_RIGHT[0][1], GRW_COORDS_RIGHT[0][2]);
        if (distLeft <= distRight) coords = GRW_COORDS_LEFT;
        else coords = GRW_COORDS_RIGHT;
        string = GOING_INTO_REAL_WAR_STRING;
        end_String = NpcString.S1_THAT_MAN_IN_FRONT_IS_HOLDEN;
        break;
      default:
        return false;
    }

    // Нужно всё это переписать.
    // This NPC is running
    actor.setRunning();
    if (actor.getDistance(target) < 100 || currentState == 0 || currentState >= coords.length) {
      if (currentState < coords.length) {
        actor.moveToLocation(
            coords[currentState][0],
            coords[currentState][1],
            coords[currentState][2],
            Rnd.get(0, 50),
            true);
        if (actor.getDestination() == null) {
          ++currentState;
        }
      } else {
        Functions.npcSay(actor, end_String, target.getName());
        actor.deleteMe();
      }
    } else if (lastSayTime + SAY_INTERVAL < System.currentTimeMillis()
        && actor.getDestination() == null) {
      int heading = actor.calcHeading(target.getX(), target.getY());
      actor.setHeading(heading);
      actor.broadcastPacket(new ExRotation(actor.getObjectId(), heading));
      lastSayTime = System.currentTimeMillis();
      Functions.npcSay(actor, string, target.getName());
    }

    return true;
  }
Пример #15
0
 @Override
 protected void onCreate() {
   super.onCreate();
   addSpawnWithoutRespawn(Anchor, zakenTp[Rnd.get(zakenTp.length)], 0);
   _savedTime = System.currentTimeMillis();
 }