Ejemplo n.º 1
0
  @Override
  public boolean wasHit(Monster monster, Fighter attacker, long damage) {
    if (ManagerPool.guildFlagManager.getFlagwarstatus() != 1) {
      return false;
    }

    if (ManagerPool.guildFlagManager.getflagmonidlist().contains(monster.getModelId())) {
      Player player = null;
      if (attacker instanceof Player) {
        player = (Player) attacker;
      } else if (attacker instanceof Pet) {
        player = ManagerPool.petInfoManager.getPetHost((Pet) attacker);
      }
      if (player != null) {
        ManagerPool.guildFlagManager.addFlagWarJF(player, 1);
        // 给玩家加攻击者BUFF
        List<Buff> buff = ManagerPool.buffManager.getBuffByModelId(player, BuffConst.FLAG_BUFF);
        if (buff.size() == 0) {
          ManagerPool.buffManager.removeByBuffId(player, BuffConst.FLAG_DEF_BUFF);
          ManagerPool.buffManager.addBuff(player, player, BuffConst.FLAG_BUFF, 0, 0, 0);
        }
        double hpdou = ((double) monster.getHp() / (double) monster.getMaxHp()) * 100;
        int hp = (int) hpdou;

        // 由于系统得不到战盟名字,,只好在这里做个缓存,所有参与的战盟名字都会被记录下来
        if (player.getGuildId() > 0
            && !GuildFlagManager.guildnamemap.containsKey(player.getGuildId())) {
          GuildFlagManager.guildnamemap.put(
              player.getGuildId(), player.getGuildInfo().getGuildName());
        }
        if (hp % 10 == 0) {
          Q_mapBean mapdb =
              ManagerPool.dataManager.q_mapContainer.getMap().get(monster.getMapModelId());
          String name = mapdb.getQ_map_name();
          GuildTerritoryFlag territory =
              ManagerPool.guildFlagManager.getTerritorymap().get(monster.getMapModelId());
          if (territory != null) {
            if (!monster.getParameters().containsKey("hp")) {
              monster.getParameters().put("hp", hp);
            }
            int oldhp = (Integer) monster.getParameters().get("hp");
            if (oldhp != hp) {
              monster.getParameters().put("hp", hp);
              if (hp > 50) {
                MessageUtil.notify_guild_all(
                    territory.getGuildid(),
                    String.format("本盟安插在【%s】地图的盟旗遭受攻击,剩余%s%血量", name, hp + ""));
              } else if (hp > 1) {
                MessageUtil.notify_guild_all(
                    territory.getGuildid(),
                    String.format("本盟安插在【%s】地图的盟旗仅剩余%s%血量,帮内弟兄赶紧前往讨伐敌人,守护盟旗!", name, hp + ""));
              }
            }
          }
        }
      }
    }
    return false;
  }
Ejemplo n.º 2
0
  /** 比武岛旗帜抢夺 开始,检查 */
  @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("没有加入战盟,不能夺旗"));
    }
  }
Ejemplo n.º 3
0
  /** 比武岛旗帜抢夺 结束 */
  @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);
  }