So im trying to get NPC vs NPC working, more specifically i want them to be aggressive.These methods are all in NPC Handler This is what i have so far:
Code:
public boolean npcVsNpc(int i)
{
switch (npcs[i].npcType) {
case 118:
case 3200:
case 1007:
return true;
}
return false;
}
Code:
public int getCloseNpc(int i) {
ArrayList<Integer> npcs = new ArrayList<Integer>();
for (int j = 0; j < NPCHandler.npcs.length; j++) {
if (NPCHandler.npcs[j] != null
&& (goodDistance(NPCHandler.npcs[j].getAbsX(),
NPCHandler.npcs[j].getAbsY(),
NPCHandler.npcs[i].getAbsX(), NPCHandler.npcs[i].getAbsY(),
7 + followDistance(i))
|| isFightCaveNpc(i)
|| isRFDNpc(i)
|| isBarbarianNpc(i))
&& ((NPCHandler.npcs[j].underAttackBy <= 0 && NPCHandler.npcs[j].underAttackBy2 <= 0) || NPCHandler.npcs[j]
.inMulti())
&& NPCHandler.npcs[j].heightLevel == NPCHandler.npcs[i].heightLevel) {
npcs.add(j);
}
}
return npcs.size() > 0 ? npcs
.get(Misc.random(npcs.size() - 1)) : 0;
}
This is in process in NPCHandler
Code:
if (npcVsNpc(i) && !npcs[i].isDead) {
npcs[i].underAttack = true;
npcs[i].killerId = getCloseNpc(i);
}
The problem is thats its not working, they are not attacking or going close to an npc. Any ideas?