Search in sources :

Example 1 with NpcConfig

use of org.powerbot.bot.rt4.client.NpcConfig in project powerbot by powerbot.

the class Npc method id.

@Override
public int id() {
    final NpcConfig d = npc.getConfig();
    if (d.isNull()) {
        return -1;
    }
    final CacheNpcConfig cacheConfig = cacheNpcConfig == null ? (cacheNpcConfig = CacheNpcConfig.load(d.getId())) : cacheNpcConfig;
    if (!cacheConfig.valid()) {
        return d.getId();
    }
    final int varbit = cacheConfig.scriptId, varp = cacheConfig.configId;
    int index = -1;
    if (varbit != -1) {
        final CacheVarbitConfig varbitConfig = cacheVarbitConfig == null ? (cacheVarbitConfig = CacheVarbitConfig.load(Bot.CACHE_WORKER, varbit)) : cacheVarbitConfig;
        if (varbitConfig != null) {
            final int mask = lookup[varbitConfig.upperBitIndex - varbitConfig.lowerBitIndex];
            index = ctx.varpbits.varpbit(varbitConfig.configId, varbitConfig.lowerBitIndex, mask);
        }
    } else if (varp != -1) {
        index = varp;
    }
    if (index >= 0) {
        final int[] children = cacheConfig.childrenIds;
        if (children.length > 0) {
            if (index >= children.length) {
                // set default child index
                index = children.length - 1;
            }
            final int child;
            if ((child = children[index]) != -1) {
                return child;
            }
        }
    }
    return d.getId();
}
Also used : NpcConfig(org.powerbot.bot.rt6.client.NpcConfig)

Example 2 with NpcConfig

use of org.powerbot.bot.rt4.client.NpcConfig in project powerbot by powerbot.

the class Npc method getOverheadArray2.

private short[] getOverheadArray2() {
    final NpcConfig d = npc.getConfig();
    final short[] arr1 = npc.getOverhead().getArray2(), arr2 = d.getOverheadArray2();
    return arr1 != null ? arr1 : arr2 != null ? arr2 : new short[0];
}
Also used : NpcConfig(org.powerbot.bot.rt6.client.NpcConfig)

Example 3 with NpcConfig

use of org.powerbot.bot.rt4.client.NpcConfig in project powerbot by powerbot.

the class Npc method id.

@Override
public int id() {
    final Client client = ctx.client();
    if (client == null) {
        return -1;
    }
    final NpcConfig c = npc == null ? new NpcConfig(client.reflector, null) : npc.getConfig();
    if (c.isNull()) {
        return -1;
    }
    final int varbit = c.getVarbit(), si = c.getVarpbitIndex();
    int index = -1;
    if (varbit != -1) {
        final Cache cache = client.getVarbitCache();
        final Varbit varBit = HashTable.lookup(cache.getTable(), varbit, Varbit.class);
        if (!varBit.isNull()) {
            final int mask = lookup[varBit.getEndBit() - varBit.getStartBit()];
            index = ctx.varpbits.varpbit(varBit.getIndex()) >> varBit.getStartBit() & mask;
        }
    } else if (si != -1) {
        index = ctx.varpbits.varpbit(si);
    }
    if (index >= 0) {
        final int[] configs = c.getConfigs();
        if (index < configs.length && configs[index] != -1) {
            return configs[index];
        }
    }
    return c.getId();
}
Also used : NpcConfig(org.powerbot.bot.rt4.client.NpcConfig) Varbit(org.powerbot.bot.rt4.client.Varbit) Client(org.powerbot.bot.rt4.client.Client) Cache(org.powerbot.bot.rt4.client.Cache)

Example 4 with NpcConfig

use of org.powerbot.bot.rt4.client.NpcConfig in project powerbot by powerbot.

the class Npc method getOverheadArray1.

private int[] getOverheadArray1() {
    final NpcConfig d = npc.getConfig();
    final int[] arr1 = npc.getOverhead().getArray1(), arr2 = d.getOverheadArray1();
    return arr1 != null ? arr1 : arr2 != null ? arr2 : new int[0];
}
Also used : NpcConfig(org.powerbot.bot.rt6.client.NpcConfig)

Aggregations

NpcConfig (org.powerbot.bot.rt6.client.NpcConfig)3 Cache (org.powerbot.bot.rt4.client.Cache)1 Client (org.powerbot.bot.rt4.client.Client)1 NpcConfig (org.powerbot.bot.rt4.client.NpcConfig)1 Varbit (org.powerbot.bot.rt4.client.Varbit)1