@Override
 public void act(Player player, Item parentItem, HouseObject<?> targetHouseObject) {
   if (!player.getInventory().decreaseByObjectId(parentItem.getObjectId(), 1)) {
     return;
   }
   if (color.equals("no")) {
     targetHouseObject.setColor(null);
   } else {
     targetHouseObject.setColor(Integer.parseInt(color, 16));
   }
   float x = targetHouseObject.getX();
   float y = targetHouseObject.getY();
   float z = targetHouseObject.getZ();
   int rotation = targetHouseObject.getRotation();
   PacketSendUtility.sendPacket(player, new SM_HOUSE_EDIT(7, 0, targetHouseObject.getObjectId()));
   PacketSendUtility.sendPacket(
       player, new SM_HOUSE_EDIT(5, targetHouseObject.getObjectId(), x, y, z, rotation));
   targetHouseObject.spawn();
   int objectName = targetHouseObject.getObjectTemplate().getNameId();
   if (color.equals("no")) {
     PacketSendUtility.sendPacket(
         player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_REMOVE_SUCCEED(objectName));
   } else {
     int paintName = parentItem.getItemTemplate().getNameId();
     PacketSendUtility.sendPacket(
         player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_SUCCEED(objectName, paintName));
   }
 }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    final QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (qs == null) return false;

    int var = qs.getQuestVarById(0);
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();

    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 204501) return defaultQuestEndDialog(env);
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 204020) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 0) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
        case 10000:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    } else if (targetId == 204501) {
      switch (env.getDialogId()) {
        case 25:
          if (var == 1) return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
          else if (var == 2)
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1693);
        case 33:
          if (QuestService.collectItemCheck(env, true)) {
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(player, qs);
            return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 5);
          } else return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 10001);
        case 1353:
          PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 191));
          break;
        case 10001:
          if (var == 1) {
            qs.setQuestVarById(0, var + 1);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    if (targetId == 0) {
      if (env.getDialogId() == 1002) {
        QuestService.startQuest(env, QuestStatus.START);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      }
    } else if (targetId == 278039) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == 25)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
        else if (env.getDialogId() == 10000) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(player, qs);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return defaultQuestStartDialog(env);
      }
    } else if (targetId == 279027) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
        if (env.getDialogId() == 25)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1693);
        else if (env.getDialogId() == 10001) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(player, qs);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return defaultQuestStartDialog(env);
      }
    } else if (targetId == 798317) {
      if (qs != null) {
        if (env.getDialogId() == 25 && qs.getStatus() == QuestStatus.START) {
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
        } else if (env.getDialogId() == 1009) {
          ItemService.removeItemFromInventoryByItemId(player, 182207048);
          qs.setQuestVar(1);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(player, qs);
          return defaultQuestEndDialog(env);
        } else return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (targetId == 798103) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == 25)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
        else return defaultQuestStartDialog(env);
      } else if (qs.getStatus() == QuestStatus.START) {
        if (env.getDialogId() == 25)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
        else if (env.getDialogId() == 1009) {
          qs.setQuestVar(3);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(player, qs);
          return defaultQuestEndDialog(env);
        } else return defaultQuestEndDialog(env);
      } else if (qs.getStatus() == QuestStatus.REWARD) {
        return defaultQuestEndDialog(env);
      }
    } else if (targetId == 798026) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
        if (env.getDialogId() == 25)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
        else if (env.getDialogId() == 10000) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(player, qs);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return defaultQuestStartDialog(env);
      }
    } else if (targetId == 798357) {
      if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) {
        if (env.getDialogId() == 25)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
        else if (env.getDialogId() == 10000) {
          qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
          updateQuestStatus(player, qs);
          PacketSendUtility.sendPacket(
              player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          return true;
        } else return defaultQuestStartDialog(env);
      }
    }

    return false;
  }
 public void startIronWallRegistration() {
   registerAvailable = true;
   startUregisterIronWallTask();
   Iterator<Player> iter = World.getInstance().getPlayersIterator();
   while (iter.hasNext()) {
     Player player = iter.next();
     if (player.getLevel() > minlevel && player.getLevel() < maxlevel) {
       PacketSendUtility.sendPacket(
           player, new SM_AUTO_GROUP(maskId, SM_AUTO_GROUP.wnd_EntryIcon));
       // You may participate in the Iron Wall Warfront.
       PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_INSTANCE_OPEN_BASTION_WAR);
     }
   }
 }
 public void onEnterWorld(Player player) {
   switch (player.getRace()) {
     case ELYOS:
       if (player.getWorldId() == 700010000) {
         PacketSendUtility.sendPacket(player, new SM_TOWNS_LIST(elyosTowns));
       }
       break;
     case ASMODIANS:
       if (player.getWorldId() == 710010000) {
         PacketSendUtility.sendPacket(player, new SM_TOWNS_LIST(asmosTowns));
       }
       break;
   }
 }
示例#7
0
 @Override
 public boolean onDialogEvent(QuestEnv env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (targetId == 204754) {
     if (qs == null || qs.getStatus() == QuestStatus.NONE) {
       if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1011);
       else return sendQuestStartDialog(env);
     } else if (qs != null && qs.getStatus() == QuestStatus.START) {
       if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 2375);
       else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id()) {
         qs.setStatus(QuestStatus.REWARD);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return sendQuestEndDialog(env);
     } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) {
       return sendQuestEndDialog(env);
     }
   } else if (targetId == 204701) {
     if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) {
       if (env.getDialog() == DialogAction.QUEST_SELECT) return sendQuestDialog(env, 1352);
       else if (env.getDialog() == DialogAction.SETPRO1) {
         qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
         return true;
       } else return sendQuestStartDialog(env);
     }
   } else if (targetId == 204768) {
     if (qs != null) {
       if (env.getDialog() == DialogAction.QUEST_SELECT && qs.getStatus() == QuestStatus.START)
         return sendQuestDialog(env, 2375);
       else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id()
           && qs.getStatus() != QuestStatus.COMPLETE
           && qs.getStatus() != QuestStatus.NONE) {
         qs.setQuestVar(3);
         qs.setStatus(QuestStatus.REWARD);
         updateQuestStatus(env);
         return sendQuestEndDialog(env);
       } else return sendQuestEndDialog(env);
     }
   }
   return false;
 }
示例#8
0
  private void destroy(final int var, final QuestEnv env) {
    final int targetObjectId = env.getVisibleObject().getObjectId();

    final Player player = env.getPlayer();
    PacketSendUtility.sendPacket(
        player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
    PacketSendUtility.broadcastPacket(
        player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {

              @Override
              public void run() {
                if (player.getTarget() == null
                    || player.getTarget().getObjectId() != targetObjectId) return;
                PacketSendUtility.sendPacket(
                    player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                    true);
                sendEmotion(env, player, EmotionId.STAND, true);
                QuestState qs = player.getQuestStateList().getQuestState(questId);
                if (var != -1) qs.setQuestVarById(0, var);
                else {
                  playQuestMovie(env, 21);
                  qs.setStatus(QuestStatus.REWARD);
                }
                updateQuestStatus(env);
              }
            },
            3000);
  }
 @Override
 public boolean onEnterWorldEvent(QuestEnv env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null && qs.getStatus() == QuestStatus.START) {
     int var = qs.getQuestVars().getQuestVars();
     if (player.getWorldId() != 320070000) {
       if (var >= 95 && var <= 99) {
         removeStigma(env);
         qs.setQuestVar(4);
         updateQuestStatus(env);
         PacketSendUtility.sendPacket(
             player,
             new SM_SYSTEM_MESSAGE(
                 SystemMessageId.QUEST_FAILED_$1,
                 DataManager.QUEST_DATA.getQuestById(questId).getName()));
         return true;
       } else if (var == 9) {
         removeStigma(env);
         return true;
       }
     }
   }
   return false;
 }
  private void destroy(final int var, QuestEnv env) {
    final int targetObjectId = env.getVisibleObject().getObjectId();

    final Player player = env.getPlayer();
    PacketSendUtility.sendPacket(
        player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
    PacketSendUtility.broadcastPacket(
        player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true);
    ThreadPoolManager.getInstance()
        .schedule(
            new Runnable() {
              @Override
              public void run() {
                if (player.getTarget().getObjectId() != targetObjectId) return;
                PacketSendUtility.sendPacket(
                    player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                PacketSendUtility.broadcastPacket(
                    player,
                    new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId),
                    true);
                PacketSendUtility.broadcastPacket(
                    player.getTarget(),
                    new SM_EMOTION((Creature) player.getTarget(), EmotionType.EMOTE, 128, 0));
                QuestState qs = player.getQuestStateList().getQuestState(questId);
                if (var == -1) PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 56));
                qs.setQuestVarById(0, qs.getQuestVarById(0) + 1);
                updateQuestStatus(player, qs);
              }
            },
            3000);
  }
 @Override
 public boolean canAct(Player player, Item parentItem, HouseObject<?> targetHouseObject) {
   if (targetHouseObject == null) {
     PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_COLOR_ERROR);
     return false;
   }
   if (color.equals("no") && targetHouseObject.getColor() == null) {
     PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_ERROR_CANNOTREMOVE);
     return false;
   }
   boolean canPaint = targetHouseObject.getObjectTemplate().getCanDye();
   if (!canPaint) {
     PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_ERROR_CANNOTPAINT);
   }
   return canPaint;
 }
示例#12
0
文件: Skill.java 项目: soulxj/aion-cn
  /**
   * Check if the skill can be used
   *
   * @return True if the skill can be used
   */
  public boolean canUseSkill() {
    Properties properties = skillTemplate.getProperties();
    if (properties != null && !properties.validate(this)) {
      log.debug("properties failed");
      return false;
    }

    if (!preCastCheck()) return false;

    // check for counter skill
    if (effector instanceof Player) {
      Player player = (Player) effector;
      if (this.skillTemplate.getCounterSkill() != null) {
        long time = player.getLastCounterSkill(skillTemplate.getCounterSkill());
        if ((time + 5000) < System.currentTimeMillis()) {
          log.debug("chain skill failed, too late");
          return false;
        }
      }

      if (skillMethod == SkillMethod.ITEM
          && duration > 0
          && player.getMoveController().isInMove()) {
        PacketSendUtility.sendPacket(
            player,
            SM_SYSTEM_MESSAGE.STR_ITEM_CANCELED(new DescriptionId(getItemTemplate().getNameId())));
        return false;
      }
    }
    if (!validateEffectedList()) return false;

    return true;
  }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    if (targetId == 0) {
      if (env.getDialogId() == 1002) {
        QuestService.startQuest(env, QuestStatus.START);
        PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0));
        return true;
      }
    } else if (targetId == 203075) {
      if (qs != null) {
        if (env.getDialogId() == 25 && qs.getStatus() == QuestStatus.START) {
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
        } else if (env.getDialogId() == 1009) {
          player.getInventory().removeFromBagByItemId(182200501, 1);
          qs.setQuestVar(1);
          qs.setStatus(QuestStatus.REWARD);
          updateQuestStatus(player, qs);
          return defaultQuestEndDialog(env);
        } else return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
示例#14
0
  @Override
  public boolean onDialogSelect(Player player, int dialogId, int questId, int extendedRewardIndex) {
    DialogPage page = DialogPage.getPageByAction(dialogId);
    if (page == DialogPage.NULL) return false;

    PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getOwner().getObjectId(), page.id()));
    return true;
  }
示例#15
0
 @Override
 protected void handleAttack(Creature creature) {
   if (getLifeStats().isFullyRestoredHp()) {
     for (Player member : getOwner().getCurrentMemberList()) {
       PacketSendUtility.sendPacket(member, SM_SYSTEM_MESSAGE.STR_BINDSTONE_IS_ATTACKED);
     }
   }
 }
 @Override
 public boolean onDialogEvent(QuestEnv env) {
   final Player player = env.getPlayer();
   int targetId = 0;
   if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null) {
     if (targetId == 205130) {
       if (env.getDialogId() == 25)
         return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
       else return defaultQuestStartDialog(env);
     }
   } else if (qs.getStatus() == QuestStatus.START) {
     switch (targetId) {
       case 730107:
         {
           if (qs.getQuestVarById(0) == 0 && env.getDialogId() == -1) {
             final int targetObjectId = env.getVisibleObject().getObjectId();
             PacketSendUtility.sendPacket(
                 player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1));
             PacketSendUtility.broadcastPacket(
                 player, new SM_EMOTION(player, 37, 0, targetObjectId), true);
             ThreadPoolManager.getInstance()
                 .schedule(
                     new Runnable() {
                       @Override
                       public void run() {
                         if (!player.isTargeting(targetObjectId)) return;
                         PacketSendUtility.sendPacket(
                             player,
                             new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0));
                         PacketSendUtility.broadcastPacket(
                             player, new SM_EMOTION(player, 38, 0, targetObjectId), true);
                         qs.setQuestVarById(0, 1);
                         updateQuestStatus(player, qs);
                       }
                     },
                     3000);
           }
         }
       case 205130:
         {
           if (qs.getQuestVarById(0) == 1) {
             if (env.getDialogId() == 25)
               return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
             else if (env.getDialogId() == 1009) {
               qs.setStatus(QuestStatus.REWARD);
               updateQuestStatus(player, qs);
               return defaultQuestEndDialog(env);
             } else return defaultQuestEndDialog(env);
           }
         }
     }
   } else if (qs.getStatus() == QuestStatus.REWARD) {
     if (targetId == 205130) return defaultQuestEndDialog(env);
   }
   return false;
 }
 @Override
 public boolean onReviveEvent(Player player) {
   PlayerReviveService.revive(player, 25, 25, false, 0);
   player.getGameStats().updateStatsAndSpeedVisually();
   PacketSendUtility.sendPacket(player, STR_REBIRTH_MASSAGE_ME);
   TeleportService2.teleportTo(
       player, mapId, instanceId, 749.6575f, 558.4166f, 572.97394f, (byte) 90);
   return true;
 }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    int targetId = 0;
    if (env.getVisibleObject() instanceof Npc) {
      targetId = ((Npc) env.getVisibleObject()).getNpcId();
    }
    QuestState qs = player.getQuestStateList().getQuestState(questId);
    if (targetId == 204777) {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialog() == DialogAction.QUEST_SELECT) {
          return sendQuestDialog(env, 1011);
        } else {
          return sendQuestStartDialog(env);
        }
      }
    }
    if (qs == null) {
      return false;
    }

    int var = qs.getQuestVarById(0);
    if (qs.getStatus() == QuestStatus.REWARD) {
      if (targetId == 204777) {
        if (env.getDialog() == DialogAction.USE_OBJECT) {
          return sendQuestDialog(env, 2375);
        } else if (env.getDialogId() == DialogAction.SELECT_QUEST_REWARD.id()) {
          return sendQuestDialog(env, 5);
        } else {
          return sendQuestEndDialog(env);
        }
      }
    } else if (qs.getStatus() != QuestStatus.START) {
      return false;
    }
    if (targetId == 204790) {
      switch (env.getDialog()) {
        case QUEST_SELECT:
          if (var == 0) {
            return sendQuestDialog(env, 1352);
          }
        case SETPRO1:
          if (var == 0) {
            qs.setQuestVarById(0, var + 1);
            qs.setStatus(QuestStatus.REWARD);
            if (!giveQuestItem(env, 182204489, 1)) {
              updateQuestStatus(env);
            }
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
            return true;
          }
          return false;
      }
    }
    return false;
  }
  @Override
  public boolean canAct(Player player, Item parentItem, Item targetItem) {
    if (targetItem == null) { // no item selected.
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_ERROR);
      return false;
    }

    return true;
  }
示例#20
0
 @Override
 public boolean onDialogSelect(
     final Player player, int dialogId, int questId, int extendedRewardIndex) {
   if (dialogId == DialogAction.SETPRO1.id()) {
     AI2Actions.deleteOwner(this);
   } else if (dialogId == DialogAction.SELECT_ACTION_1012.id())
     PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 1012));
   return true;
 }
  @Override
  public boolean onDialogEvent(QuestEnv env) {
    final Player player = env.getPlayer();
    int targetId = 0;

    QuestState qs2 = player.getQuestStateList().getQuestState(3968);
    if (qs2 == null || qs2.getStatus() != QuestStatus.COMPLETE) return false;

    if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId();
    QuestState qs = player.getQuestStateList().getQuestState(questId);

    if (targetId == 798390) // Palentine
    {
      if (qs == null || qs.getStatus() == QuestStatus.NONE) {
        if (env.getDialogId() == -1)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1011);
        else if (env.getDialogId() == 1002) {
          if (ItemService.addItems(
              player, Collections.singletonList(new QuestItems(182206126, 1)))) {
            return defaultQuestStartDialog(env);
          }
          return true;
        } else return defaultQuestStartDialog(env);
      }
    }

    if (qs == null) return false;

    int var = qs.getQuestVarById(0);

    if (targetId == 798391) // Andu
    {
      if (qs.getStatus() == QuestStatus.START && var == 0) {
        if (env.getDialogId() == -1)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 1352);
        else if (env.getDialogId() == 10000) {
          if (ItemService.removeItemFromInventoryByItemId(player, 182206126)) {
            qs.setQuestVar(1);
            qs.setStatus(QuestStatus.REWARD);
            updateQuestStatus(player, qs);
            PacketSendUtility.sendPacket(
                player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10));
          }
          return true;
        } else return defaultQuestStartDialog(env);
      }
    } else if (targetId == 798390) // Palentine
    {
      if (qs.getStatus() == QuestStatus.REWARD) {
        if (env.getDialogId() == -1)
          return sendQuestDialog(player, env.getVisibleObject().getObjectId(), 2375);
        return defaultQuestEndDialog(env);
      }
    }
    return false;
  }
 @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");
   }
 }
示例#23
0
  @Override
  public void see(VisibleObject object) {
    if (!isMaster) return;

    if (object instanceof Player) {
      PacketSendUtility.sendPacket(
          (Player) object,
          new SM_RIFT_STATUS(getOwner().getObjectId(), usedEntries, maxEntries, maxLevel));
    }
  }
  /**
   * Shows Question window and expands on positive response
   *
   * @param player
   * @param npc
   */
  public static void expandCube(final Player player, Npc npc) {
    final CubeExpandTemplate expandTemplate =
        DataManager.CUBEEXPANDER_DATA.getCubeExpandListTemplate(npc.getNpcId());

    if (expandTemplate == null) {
      log.error("Cube Expand Template could not be found for Npc ID: " + npc.getObjectId());
      return;
    }

    if (npcCanExpandLevel(expandTemplate, player.getCubeSize() + 1)
        && validateNewSize(player.getCubeSize() + 1)) {
      /** Check if our player can pay the cubic expand price */
      final int price = getPriceByLevel(expandTemplate, player.getCubeSize() + 1);

      RequestResponseHandler responseHandler =
          new RequestResponseHandler(npc) {
            @Override
            public void acceptRequest(StaticNpc requester, Player responder) {
              if (!ItemService.decreaseKinah(responder, price)) {
                PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.CUBEEXPAND_NOT_ENOUGH_KINAH);
                return;
              }
              expand(responder);
            }

            @Override
            public void denyRequest(StaticNpc requester, Player responder) {
              // nothing to do
            }
          };

      boolean result =
          player
              .getResponseRequester()
              .putRequest(SM_QUESTION_WINDOW.STR_WAREHOUSE_EXPAND_WARNING, responseHandler);
      if (result) {
        PacketSendUtility.sendPacket(
            player,
            new SM_QUESTION_WINDOW(
                SM_QUESTION_WINDOW.STR_WAREHOUSE_EXPAND_WARNING, 0, String.valueOf(price)));
      }
    } else PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300430));
  }
示例#25
0
  @Override
  protected void handleDialogStart(Player player) {
    if (player.getKisk() == getOwner()) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_BINDSTONE_ALREADY_REGISTERED);
      return;
    }

    if (getOwner().canBind(player)) {
      AI2Actions.addRequest(
          this,
          player,
          SM_QUESTION_WINDOW.STR_ASK_REGISTER_BINDSTONE,
          getOwner().getObjectId(),
          CANCEL_DIALOG_METERS,
          new AI2Request() {
            private boolean decisionTaken = false;

            @Override
            public void acceptRequest(Creature requester, Player responder) {
              if (!decisionTaken) {
                // Check again if it's full (If they waited to press OK)
                if (!getOwner().canBind(responder)) {
                  PacketSendUtility.sendPacket(
                      responder, SM_SYSTEM_MESSAGE.STR_CANNOT_REGISTER_BINDSTONE_HAVE_NO_AUTHORITY);
                  return;
                }
                KiskService.getInstance().onBind(getOwner(), responder);
              }
            }

            @Override
            public void denyRequest(Creature requester, Player responder) {
              decisionTaken = true;
            }
          });

    } else if (getOwner().getCurrentMemberCount() >= getOwner().getMaxMembers()) {
      PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_CANNOT_REGISTER_BINDSTONE_FULL);
    } else {
      PacketSendUtility.sendPacket(
          player, SM_SYSTEM_MESSAGE.STR_CANNOT_REGISTER_BINDSTONE_HAVE_NO_AUTHORITY);
    }
  }
  // necessary overloading to not change AbstractItemAction
  public void act(
      final Player player,
      final Item parentItem,
      final Item targetItem,
      final Item supplementItem) {
    PacketSendUtility.sendPacket(
        player,
        new SM_ITEM_USAGE_ANIMATION(
            player.getObjectId(),
            parentItem.getObjectId(),
            parentItem.getItemTemplate().getTemplateId(),
            5000,
            0,
            0));
    player.cancelTask(TaskId.ITEM_USE);
    player.addNewTask(
        TaskId.ITEM_USE,
        ThreadPoolManager.getInstance()
            .schedule(
                new Runnable() {
                  @Override
                  public void run() {

                    int itemId = parentItem.getItemTemplate().getTemplateId();
                    if (itemId > 166000000 && itemId < 167000000) {
                      boolean result =
                          EnchantService.enchantItem(
                              player, parentItem, targetItem, supplementItem);
                      PacketSendUtility.sendPacket(
                          player,
                          new SM_ITEM_USAGE_ANIMATION(
                              player.getObjectId(),
                              parentItem.getObjectId(),
                              parentItem.getItemTemplate().getTemplateId(),
                              0,
                              result ? 1 : 2,
                              0));
                    } else {
                      boolean result =
                          EnchantService.socketManastone(
                              player, parentItem, targetItem, supplementItem);
                      PacketSendUtility.sendPacket(
                          player,
                          new SM_ITEM_USAGE_ANIMATION(
                              player.getObjectId(),
                              parentItem.getObjectId(),
                              parentItem.getItemTemplate().getTemplateId(),
                              0,
                              result ? 1 : 2,
                              0));
                    }
                  }
                },
                5000));
  }
示例#27
0
 @Override
 public boolean onEnterWorldEvent(QuestEnv env) {
   Player player = env.getPlayer();
   QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs != null && qs.getStatus() == QuestStatus.START) {
     int var = qs.getQuestVars().getQuestVars();
     if (var == 4 || (var >= 50 && var <= 55) || var == 99) {
       if (player.getWorldId() != 310010000) {
         qs.setQuestVar(3);
         updateQuestStatus(player, qs);
         PacketSendUtility.sendPacket(
             player,
             new SM_SYSTEM_MESSAGE(
                 SystemMessageId.QUEST_FAILED_$1, questsData.getQuestById(questId).getName()));
       } else {
         PacketSendUtility.sendPacket(player, new SM_ASCENSION_MORPH(1));
         return true;
       }
     }
   }
   return false;
 }
示例#28
0
 @Override
 public boolean onEnterZoneEvent(QuestEnv env, ZoneName zoneName) {
   if (zoneName != ZoneName.Q1123) return false;
   final Player player = env.getPlayer();
   final QuestState qs = player.getQuestStateList().getQuestState(questId);
   if (qs == null || qs.getQuestVars().getQuestVars() != 0) return false;
   env.setQuestId(questId);
   PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 11));
   qs.setStatus(QuestStatus.REWARD);
   qs.getQuestVars().setQuestVarById(0, 1);
   updateQuestStatus(player, qs);
   return true;
 }
示例#29
0
  @Override
  protected void runImpl() {

    final Player player = getConnection().getActivePlayer();
    boolean haveUnreadExpress =
        (player.getMailbox().haveUnreadByType(LetterType.EXPRESS)
            || player.getMailbox().haveUnreadByType(LetterType.BLACKCLOUD));
    switch (this.action) {
      case 0:
        // window is closed
        if (player.getPostman() != null) {
          player.getPostman().getController().onDelete();
          player.setPostman(null);
        }
        break;
      case 1:
        // click on icon
        if (player.getPostman() != null) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_POSTMAN_ALREADY_SUMMONED);
        } else if (player.isFlying()) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_POSTMAN_UNABLE_IN_FLIGHT);
        } else if (player.getController().hasTask(TaskId.EXPRESS_MAIL_USE)) {
          PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_POSTMAN_UNABLE_IN_COOLTIME);
        } else if (haveUnreadExpress) {
          VisibleObjectSpawner.spawnPostman(player);
          Future<?> task =
              ThreadPoolManager.getInstance()
                  .schedule(
                      new Runnable() {
                        @Override
                        public void run() {}
                      },
                      600000); // 10 min
          player.getController().addTask(TaskId.EXPRESS_MAIL_USE, task);
        }
        break;
    }
  }
 @Override
 public boolean onDie(final Player player, Creature lastAttacker) {
   PacketSendUtility.broadcastPacket(
       player,
       new SM_EMOTION(
           player,
           EmotionType.DIE,
           0,
           player.equals(lastAttacker) ? 0 : lastAttacker.getObjectId()),
       true);
   PacketSendUtility.sendPacket(
       player, new SM_DIE(player.haveSelfRezEffect(), player.haveSelfRezItem(), 0, 8));
   return true;
 }