Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }