All pastes #717794 Raw Edit

Something

public text v1 · immutable
#717794 ·published 2007-09-27 21:30 UTC
rendered paste body
	private L2Character findNextRndTarget(double aggroRange) 
    {
        L2Attackable npc = (L2Attackable)_actor;
        double dblAggroRange = aggroRange*aggroRange;
        if(dblAggroRange == 1.0)
        	dblAggroRange = 2000;
        List<L2Character> potentialTarget = new FastList<L2Character>();
			for (L2Object obj : npc.getKnownList().getKnownObjects().values()) 
	        {
				if(!(obj instanceof L2PcInstance) || !(obj instanceof L2Summon))
					continue;
				double dist2 = ((L2Attackable)_actor).getPlanDistanceSq(obj.getX(), obj.getY());
	            if (dist2 > dblAggroRange)
	                continue;
	            
				L2Character target = (L2Character)obj;
				if(target.isDead())
					continue;
				potentialTarget.add(target);
			}
		if (potentialTarget.size() == 0) // nothing to do
			return null;
		// we choose a random target
		int choice = Rnd.nextInt(potentialTarget.size());
		L2Character target = potentialTarget.get(choice);
		return target;
	}