public Player getRandomPartyMember(int state, int maxrange, GameObject rangefrom) { List<Player> list = getPartyMembers(state, maxrange, rangefrom); if (list.size() == 0) { return null; } return list.get(Rnd.get(list.size())); }
public List<Player> getPartyMembers(int state, int maxrange, GameObject rangefrom) { List<Player> result = new ArrayList<Player>(); Party party = getPlayer().getParty(); if (party == null) { if (checkPartyMember(getPlayer(), state, maxrange, rangefrom)) { result.add(getPlayer()); } return result; } for (Player _member : party.getPartyMembers()) { if (checkPartyMember(_member, state, maxrange, rangefrom)) { result.add(getPlayer()); } } return result; }
@Override public void onKill(Creature actor, Creature victim) { if (!victim.isPlayer()) { return; } Player actorPlayer = (Player) actor; List<Player> players = null; switch (_quest.getParty()) { case Quest.PARTY_NONE: players = Collections.singletonList(actorPlayer); break; case Quest.PARTY_ALL: if (actorPlayer.getParty() == null) { players = Collections.singletonList(actorPlayer); } else { players = new ArrayList<Player>(actorPlayer.getParty().getMemberCount()); for (Player member : actorPlayer.getParty().getPartyMembers()) { if (member.isInRange(actorPlayer, Creature.INTERACTION_DISTANCE)) { players.add(member); } } } break; default: players = Collections.emptyList(); break; } for (Player player : players) { QuestState questState = player.getQuestState(_quest.getClass()); if ((questState != null) && !questState.isCompleted()) { _quest.notifyKill((Player) victim, questState); } } }