Beispiel #1
0
 /** @param npcAI */
 public static void onSpawn(NpcAI2 npcAI) {
   if (npcAI.setStateIfNot(AIState.IDLE)) {
     if (npcAI.getOwner().getPosition().isMapRegionActive()) {
       npcAI.think();
     }
   }
 }
 /** @param npcAI */
 public static void thinkAttack(NpcAI2 npcAI) {
   Npc npc = npcAI.getOwner();
   Creature mostHated = npc.getAggroList().getMostHated();
   if (mostHated != null && !mostHated.getLifeStats().isAlreadyDead()) {
     npcAI.onCreatureEvent(AIEventType.TARGET_CHANGED, mostHated);
   } else {
     npc.getMoveController().recallPreviousStep();
     npcAI.onGeneralEvent(AIEventType.ATTACK_FINISH);
     npcAI.onGeneralEvent(
         npc.isAtSpawnLocation() ? AIEventType.BACK_HOME : AIEventType.NOT_AT_HOME);
   }
 }
 @Override
 protected void handleDied() {
   super.handleDied();
   Npc freeTerma = (Npc) spawn(205495, 455.94f, 537.06f, 132.6f, (byte) 0);
   spawn(701009, 451.706f, 534.313f, 131.979f, (byte) 0);
   NpcShoutsService.getInstance().sendMsg(freeTerma, 1500444, freeTerma.getObjectId(), 0, 3000);
 }
 /** @param npcAI */
 public static void thinkIdle(NpcAI2 npcAI) {
   if (WalkManager.isWalking(npcAI)) {
     boolean startedWalking = WalkManager.startWalking(npcAI);
     if (!startedWalking) {
       npcAI.setStateIfNot(AIState.IDLE);
     }
   }
 }
 @Override
 protected void handleAttack(Creature creature) {
   super.handleAttack(creature);
   if (!isMove) {
     isMove = true;
     moveToDead();
   }
 }
  @Override
  protected void handleDespawned() {
    KiskService.getInstance().removeKisk(getOwner());
    if (!isAlreadyDead()) {
      getOwner().broadcastPacket(SM_SYSTEM_MESSAGE.STR_BINDSTONE_IS_REMOVED);
    }

    super.handleDespawned();
  }
 @Override
 protected void handleDialogStart(Player player) {
   if (player.getInventory().getItemCountByItemId(186000236) > 0) {
     super.handleDialogStart(player);
   } else {
     PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 27));
     PacketSendUtility.sendMessage(
         player, "You need item [item: 186000236] to ask reinforcements");
   }
 }
  @Override
  protected void handleDied() {
    if (isAlreadyDead()) {
      PacketSendUtility.broadcastPacket(
          getOwner(), new SM_EMOTION(getOwner(), EmotionType.DIE, 0, 0));
      getOwner().broadcastPacket(SM_SYSTEM_MESSAGE.STR_BINDSTONE_IS_DESTROYED);
    }

    super.handleDied();
  }
 /** @param npcAI */
 public static void onThink(NpcAI2 npcAI) {
   if (npcAI.isLogging()) {
     AI2Logger.info(npcAI, "think");
   }
   if (npcAI.isAlreadyDead()) {
     AI2Logger.info(npcAI, "can't think in dead state");
     return;
   }
   if (!npcAI.tryLockThink()) {
     AI2Logger.info(npcAI, "can't acquire lock");
     return;
   }
   try {
     if (!npcAI.getOwner().getPosition().isMapRegionActive()
         || npcAI.getSubState() == AISubState.FREEZE) {
       thinkInInactiveRegion(npcAI);
       return;
     }
     if (npcAI.isLogging()) {
       AI2Logger.info(npcAI, "think state " + npcAI.getState());
     }
     switch (npcAI.getState()) {
       case FIGHT:
         thinkAttack(npcAI);
         break;
       case WALKING:
         thinkWalking(npcAI);
         break;
       case IDLE:
         thinkIdle(npcAI);
         break;
       default:
         break;
     }
   } finally {
     npcAI.unlockThink();
   }
 }
Beispiel #10
0
 @Override
 protected void handleSpawned() {
   super.handleSpawned();
   int owner = getOwner().getNpcId();
   switch (owner) {
     case 283913:
       NpcShoutsService.getInstance()
           .sendMsg(getOwner(), 1500679, getOwner().getObjectId(), 0, 2000);
       break;
     case 283914:
       NpcShoutsService.getInstance()
           .sendMsg(getOwner(), 1500680, getOwner().getObjectId(), 0, 2000);
       break;
     case 283915:
       NpcShoutsService.getInstance()
           .sendMsg(getOwner(), 1500681, getOwner().getObjectId(), 0, 2000);
       break;
     case 283916:
       NpcShoutsService.getInstance()
           .sendMsg(getOwner(), 1500682, getOwner().getObjectId(), 0, 2000);
       break;
   }
   despawn();
 }
  /** @param npcAI */
  private static void thinkInInactiveRegion(NpcAI2 npcAI) {

    if (!npcAI.canThink()) {
      return;
    }

    if (npcAI.isLogging()) {
      AI2Logger.info(npcAI, "think in inactive region: " + npcAI.getState());
    }
    switch (npcAI.getState()) {
      case FIGHT:
        thinkAttack(npcAI);
        break;
      default:
        if (!npcAI.getOwner().isAtSpawnLocation()) {
          npcAI.onGeneralEvent(AIEventType.NOT_AT_HOME);
        }
    }
  }
Beispiel #12
0
 /** @param npcAI */
 public static void onRespawn(NpcAI2 npcAI) {
   npcAI.getOwner().getMoveController().resetMove();
 }
Beispiel #13
0
 /** @param npcAI */
 public static void onDespawn(NpcAI2 npcAI) {
   npcAI.setStateIfNot(AIState.DESPAWNED);
 }
Beispiel #14
0
  /** Start casting of skill */
  protected void startCast() {
    int targetObjId = firstTarget != null ? firstTarget.getObjectId() : 0;

    if (skillMethod == SkillMethod.CAST || skillMethod == SkillMethod.CHARGE) {
      switch (targetType) {
        case 0: // PlayerObjectId as Target
          PacketSendUtility.broadcastPacketAndReceive(
              effector,
              new SM_CASTSPELL(
                  effector.getObjectId(),
                  skillTemplate.getSkillId(),
                  skillLevel,
                  targetType,
                  targetObjId,
                  this.duration,
                  skillTemplate.isCharge()));
          if (effector instanceof Npc && firstTarget instanceof Player) {
            NpcAI2 ai = (NpcAI2) effector.getAi2();
            if (ai.poll(AIQuestion.CAN_SHOUT)) ShoutEventHandler.onCast(ai, firstTarget);
          }
          break;

        case 3: // Target not in sight?
          PacketSendUtility.broadcastPacketAndReceive(
              effector,
              new SM_CASTSPELL(
                  effector.getObjectId(),
                  skillTemplate.getSkillId(),
                  skillLevel,
                  targetType,
                  0,
                  this.duration,
                  skillTemplate.isCharge()));
          break;

        case 1: // XYZ as Target
          PacketSendUtility.broadcastPacketAndReceive(
              effector,
              new SM_CASTSPELL(
                  effector.getObjectId(),
                  skillTemplate.getSkillId(),
                  skillLevel,
                  targetType,
                  x,
                  y,
                  z,
                  this.duration));
          break;
      }
    } else if (skillMethod == SkillMethod.ITEM && duration > 0) {
      PacketSendUtility.broadcastPacketAndReceive(
          effector,
          new SM_ITEM_USAGE_ANIMATION(
              effector.getObjectId(),
              firstTarget.getObjectId(),
              (this.itemObjectId == 0 ? 0 : this.itemObjectId),
              itemTemplate.getTemplateId(),
              this.duration,
              0,
              0));
    }
  }
 @Override
 protected void handleSpawned() {
   super.handleSpawned();
   doorId = getNpcId() == 799661 ? 16 : 54;
 }
Beispiel #16
0
 @Override
 protected void handleSpawned() {
   super.handleSpawned();
   useskill();
 }