/** 比武岛旗帜抢夺 开始,检查 */ @Override public void defaultAction(Player player, NPC npc) { if (ManagerPool.biWuDaoManager.getBiwudaostate() != 1) { /* xuliang MessageUtil.notify_player(player, Notifys.MOUSEPOS, ResManager.getInstance().getString("现在不是比武岛活动时间,不能对旗帜操作.")); */ return; } if (player.isDie() == true) { /* xuliang MessageUtil.notify_player(player, Notifys.MOUSEPOS, ResManager.getInstance().getString("死亡状态下不能夺旗")); */ return; } if (player.getGuildId() > 0) { if (ManagerPool.biWuDaoManager.getBiwudaoguildid() == player.getGuildId()) { /* xuliang MessageUtil.notify_player(player, Notifys.MOUSEPOS, ResManager.getInstance().getString("您的战盟已经是占领者.")); */ return; } long time = System.currentTimeMillis() / 1000 - ManagerPool.biWuDaoManager.getFlagcooldown(); if (time < BiWuDaoManager.BIWUDAO_FLAGCOOLDOWNMAX) { MessageUtil.notify_player( player, Notifys.MOUSEPOS, ResManager.getInstance().getString("{1}秒后才可争夺。"), "" + (BiWuDaoManager.BIWUDAO_FLAGCOOLDOWNMAX - time)); return; } ManagerPool.npcManager.playerGather(player, npc); // 开始采集 } else { MessageUtil.notify_player( player, Notifys.MOUSEPOS, ResManager.getInstance().getString("没有加入战盟,不能夺旗")); } }
/** 点击NPC触发 */ @Override public void defaultAction(Player player, NPC npc) { try { if (!npc.getParameters().containsKey("marriageid")) { return; } long marriageid = (Long) npc.getParameters().get("marriageid"); int num = (Integer) npc.getParameters().get("num"); if (num <= 0) { MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("您的下手过慢了,该桌上的菜肴已经被吃光了")); return; } if (npc.getParameters().containsKey("player_" + player.getId())) { MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("婚宴均为流水席,您已经食用过该餐桌上的食物,无法再次食用。请转到请到下一席")); return; } if (marriageid == player.getMarriageid()) { MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("这是您自己的婚宴,请不要与宾客争夺菜肴")); return; } Marriage marriage = ManagerPool.marriageManager.getMarriage(marriageid); if (marriage == null) { return; } double distance = MapUtils.countDistance(player.getPosition(), npc.getPosition()); // 得到距离 if (distance > MapUtils.GRID_BORDER * 10) { MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("距离过远,请靠近婚宴餐桌才能享用菜肴")); return; } Wedding wedding = ManagerPool.marriageManager.getWedding(marriageid); if (wedding != null) { boolean is = false; // 默认没有给红包 for (RedEnvelope redEnvelope : wedding.getRedenvelopes()) { if (redEnvelope.getPlayerid() == player.getId()) { is = true; // 检测到已经给过红包 break; } } if (is) { // 给过红包,弹出食用婚宴界面消息 ResEdibleInfoToClientMessage cmsg = new ResEdibleInfoToClientMessage(); cmsg.setFoodnum(num); cmsg.setMarriageid(marriageid); cmsg.setNpcid(npc.getId()); long exp = ManagerPool.countManager.getCount(player, CountTypes.WEDDING_EXP, null); long zhenqi = ManagerPool.countManager.getCount(player, CountTypes.WEDDING_ZHENQI, null); cmsg.setTotalexp((int) exp); cmsg.setTotalzhenqi((int) zhenqi); cmsg.setType(wedding.getType()); cmsg.setBride(marriage.getSpouseslist().get(1).getName()); cmsg.setBridegroom(marriage.getSpouseslist().get(0).getName()); MessageUtil.tell_player_message(player, cmsg); } else { // 如果没给过红包,发下面2个消息 ResWeddingbanquetToClientMessage cmsg = new ResWeddingbanquetToClientMessage(); cmsg.setBride(marriage.getSpouseslist().get(1).getName()); cmsg.setBridegroom(marriage.getSpouseslist().get(0).getName()); cmsg.setFoodnum(num); cmsg.setNpcid(npc.getId()); cmsg.setMarriageid(marriageid); long leiji = ManagerPool.countManager.getCount(player, CountTypes.RED_ENVELOPE, null); cmsg.setTotalredenvelope((int) leiji); cmsg.setType(wedding.getType()); MessageUtil.tell_player_message(player, cmsg); ResEdibleInfoToClientMessage cmsg2 = new ResEdibleInfoToClientMessage(); cmsg2.setBride(marriage.getSpouseslist().get(1).getName()); cmsg2.setBridegroom(marriage.getSpouseslist().get(0).getName()); cmsg2.setFoodnum(num); cmsg2.setMarriageid(marriageid); cmsg2.setNpcid(npc.getId()); long exp = ManagerPool.countManager.getCount(player, CountTypes.WEDDING_EXP, null); long zhenqi = ManagerPool.countManager.getCount(player, CountTypes.WEDDING_ZHENQI, null); cmsg2.setTotalexp((int) exp); cmsg2.setTotalzhenqi((int) zhenqi); cmsg2.setType(wedding.getType()); MessageUtil.tell_player_message(player, cmsg2); } } } catch (Exception e) { log.error(e, e); } }
@Override public void gather(Player player, NPC npc) { // 根据npc判断采集物品 Q_npcBean bean = ManagerPool.dataManager.q_npcContainer.getMap().get(npc.getModelId()); if (bean == null) { return; } String itemModelIds = bean.getQ_acquisition_item(); if (StringUtil.isBlank(itemModelIds)) { // player停止采集 ManagerPool.npcManager.playerStopGather(player); return; } Map<Integer, Integer> gatherMap = new HashMap<Integer, Integer>(); String[] split = itemModelIds.split(Symbol.FENHAO_REG); for (String str : split) { String[] split2 = str.split(Symbol.XIAHUAXIAN_REG); int id = Integer.parseInt(split2[0]); int num = 1; if (split2.length > 1) num = Integer.parseInt(split2[1]); String jobLimit = null; if (split2.length > 2) jobLimit = split2[2]; if (PlayerManager.checkJob(player.getJob(), jobLimit)) gatherMap.put(id, num); } if (gatherMap.size() == 0) { log.error("没有物品可以采集了:" + bean.getQ_id()); ManagerPool.npcManager.playerStopGather(player); return; } // 判断包裹是否能够放下此物品 int num = ManagerPool.backpackManager.getEmptyGridNum(player); if (num < gatherMap.size()) { // 提示包裹空间不足 MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("背包空间不足")); // player停止采集 ManagerPool.npcManager.playerStopGather(player); return; } // 根据npc判断采集物品 String taskModelId = bean.getQ_acquisition_task(); if (StringUtil.isNotBlank(taskModelId)) { MainTask mainTask = null; for (MainTask task : player.getCurrentMainTasks()) { if (taskModelId.contains(String.valueOf(task.getModelid()))) { mainTask = task; break; } } if (mainTask == null) { return; } Q_task_mainBean taskModel = DataManager.getInstance().q_task_mainContainer.getMap().get(mainTask.getModelid()); if (player.getLevel() < taskModel.getQ_accept_needmingrade()) { // 等级不足 MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("采集需要的等级不足")); return; } // 增加player物品 List<Item> item = new ArrayList<Item>(); Iterator<Entry<Integer, Integer>> iterator = gatherMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<Integer, Integer> next = iterator.next(); List<Item> item2 = Item.createItems(next.getKey(), next.getValue(), true, 0); if (CollectionUtil.isNotBlank(item2)) item.addAll(item2); } if (BackpackManager.getInstance().hasAddSpace(player, item)) { log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")检查物品有地儿放!"); } else { log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")检查物品没地儿放!"); } if (ManagerPool.backpackManager.addItems(player, item, Reasons.TAKEUP, Config.getId())) { log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")获得物品成功!"); ; } else { log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")获得物品失败!"); ; } log.error("玩家(" + player.getId() + ")采集成功准备完成任务(" + mainTask.getModelid() + ")!"); // 触发完成任务 // mainTask.changeTask(); if (mainTask.checkFinsh(false, player)) { mainTask.finshTask(player); log.error("玩家(" + player.getId() + ")采集成功完成任务(" + taskModelId + ")了!"); } else { log.error("玩家(" + player.getId() + ")采集成功未完成任务(" + taskModelId + ")了!"); } // ManagerPool.taskManager.finishMainTask(player, taskModelId); } // player停止采集 ManagerPool.npcManager.playerStopGather(player); }
/** 比武岛旗帜抢夺 结束 */ @Override public void gather(Player player, NPC npc) { if (ManagerPool.biWuDaoManager.getBiwudaostate() != 1) { /* xuliang MessageUtil.notify_player(player, Notifys.ERROR, ResManager.getInstance().getString("现在不是比武岛活动时间,不能对旗帜操作.")); */ return; } if (player.getGuildId() > 0) { String gname = ResManager.getInstance().getString("未知战盟"); Map map = ManagerPool.mapManager.getMap(player); // npc消失 ManagerPool.npcManager.hideNpc(npc); // 夺旗剩余冷却时间地图广播 ResBiWuDaoFlagCoolDownToClientMessage cmsg = new ResBiWuDaoFlagCoolDownToClientMessage(); cmsg.setFlagcooldown(BiWuDaoManager.BIWUDAO_FLAGCOOLDOWNMAX); MessageUtil.tell_map_message(map, cmsg); GuildTmpInfo guildTmpInfo = ManagerPool.guildServerManager.getGuildTmpInfo(player.getGuildId()); if (guildTmpInfo != null) { gname = guildTmpInfo.getGuildname(); npc.setName(gname); } // 设定当前占领者和冷却开始时间 ManagerPool.biWuDaoManager.setBiwudaoguildid(player.getGuildId()); ManagerPool.biWuDaoManager.setBiwudaoguildname(gname); ManagerPool.biWuDaoManager.setFlagcooldown(System.currentTimeMillis() / 1000); // 比武岛旗帜占领者战盟名字地图广播 ResBiWuDaoGuildnameToClientMessage gmsg = new ResBiWuDaoGuildnameToClientMessage(); gmsg.setGuildid(player.getGuildId()); gmsg.setGuildname(gname); MessageUtil.tell_map_message(map, gmsg); ManagerPool.npcManager.showNpc(npc); // 夺旗者加军功 int num = 10; if (player.getBiwudaototalrank() < BiWuDaoManager.BIWUDAO_RAMKMAX) { if (BiWuDaoManager.BIWUDAO_RAMKMAX - player.getBiwudaototalrank() < num) { num = BiWuDaoManager.BIWUDAO_RAMKMAX - player.getBiwudaototalrank(); } ManagerPool.rankManager.addranknum(player, num, RankType.BIWUDAO); player.setBiwudaototalrank(player.getBiwudaototalrank() + num); } else { MessageUtil.notify_player( player, Notifys.CHAT_SYSTEM, ResManager.getInstance().getString("已到达活动可获得军功300点上限")); } ParseUtil parseUtil = new ParseUtil(); parseUtil.setValue( String.format( ResManager.getInstance().getString("【%s】的【%s】在比武岛占领战旗获得10点军功奖励,该战盟成员获得真气、经验收益翻倍!{@}"), gname, player.getName()), new ParseUtil.VipParm( VipManager.getInstance().getVIPLevel(player), GuideType.BIWUDAO_MOVE.getValue())); MessageUtil.notify_All_player( Notifys.CHAT_BULL, parseUtil.toString(), new ArrayList<GoodsInfoRes>(), GuideType.BIWUDAO_MOVE.getValue()); // player停止采集 ManagerPool.npcManager.playerStopGather(player, true); ScriptsUtils.call(ScriptEnum.BIWUDAO, "setmapbuff"); // 地图所有玩家加减BUFF return; } else { MessageUtil.notify_player( player, Notifys.ERROR, ResManager.getInstance().getString("只有战盟成员才能夺旗")); } // player停止采集 ManagerPool.npcManager.playerStopGather(player, true); }