All pastes #339887 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-02-04 11:37 UTC
rendered paste body
public final NPC getNPC(String names[], int types[], int searchConstraints) {        boolean ON_MINI_MAP = SC.isConstraintSet(searchConstraints,                SC.ON_MINI_MAP_BIT_INDEX);        boolean ON_SCREEN = SC.isConstraintSet(searchConstraints,                SC.ON_SCREEN_BIT_INDEX);        boolean NOT_IN_COMBAT_BIT_INDEX = SC.isConstraintSet(searchConstraints,                SC.NOT_IN_COMBAT);        Tile player = getTile(getPlayer());        int winnerDist = 1000;        NPC winner = null;        int[] npcIndexs = theClient.getNPCIndexArray();        NPC[] npcs = theClient.getNPCArray();        for (int i = 0; i < npcIndexs.length; i++) {            try {                NPC npc = npcs[npcIndexs[i]];                Tile npcTile = getTile(npc);                if (npc == null)                    continue;                if (ON_MINI_MAP && TileToMinimap(npcTile) == null) {                    continue;                }                if (ON_SCREEN                        && TileToScreen(npcTile, npc.getHeight() / 2) == null) {                    continue;                }                if (NOT_IN_COMBAT_BIT_INDEX && npc.getInteractingChar() != -1) {                    continue;                }                for (int nameIndex = 0; nameIndex < names.length; nameIndex++) {                    if (!names[nameIndex].equals(unwrap(npc.getNPCDef()                            .getNPCName())))                        continue;                    int challengerDist = distance(player, getTile(npc));                    if (challengerDist < winnerDist) {                        winnerDist = challengerDist;                        winner = npc;                        break;                    }                }                for (int typeIndex = 0; typeIndex < types.length; typeIndex++) {                    if (types[typeIndex] != npc.getNPCDef().getNPCType())                        continue;                    int challengerDist = distance(player, getTile(npc));                    if (challengerDist < winnerDist) {                        winnerDist = challengerDist;                        winner = npc;                        break;                    }                }            } catch (Exception e) {                exception(e);            }        }        return winner;    }