Example #1
0
  @Override
  public void onDie(Creature lastAttacker) {
    super.onDie(lastAttacker);

    Npc owner = getOwner();

    addTask(TaskId.DECAY, RespawnService.scheduleDecayTask(this.getOwner()));
    scheduleRespawn();

    PacketSendUtility.broadcastPacket(
        owner,
        new SM_EMOTION(
            owner, EmotionType.DIE, 0, lastAttacker == null ? 0 : lastAttacker.getObjectId()));

    // Monster Controller overrides this method.
    this.doReward();
    Npc npc = getOwner();
    List<QuestDrop> drops = QuestEngine.getInstance().getQuestDrop(npc.getNpcId());
    if (drops.size() > 0) {
      DropService.getInstance()
          .registerDrop(getOwner(), (Player) lastAttacker, lastAttacker.getLevel());
    }
    owner.getAi().handleEvent(Event.DIED);

    // deselect target at the end
    owner.setTarget(null);
    PacketSendUtility.broadcastPacket(owner, new SM_LOOKATOBJECT(owner));
  }
Example #2
0
  /** Schedule respawn of npc In instances - no npc respawn */
  public void scheduleRespawn() {
    if (getOwner().isInInstance()) return;

    int instanceId = getOwner().getInstanceId();
    if (!getOwner().getSpawn().isNoRespawn(instanceId)) {
      Future<?> respawnTask = RespawnService.scheduleRespawnTask(getOwner());
      addTask(TaskId.RESPAWN, respawnTask);
    }
  }