Hello!
I have one problem that annoys the crap out of me and I can't solve it, I think I am missing something really obivous too!
Ok, I made a class(CombatCaller) that controls the packet(s) that have to do with combat.
So I got the packet 72, that is Attack NPC. Here is the code for it -
Code:
static void handleAttackNPC(Packet p, Player player, ActionSender sender) {
int victim = p.readShortA();
if (NPCManager.isValid(victim)) {
Combat.attackNPC(victim, player);
}
}
The attackNPC packet ID is 72, which is what it is supposed to be.
Here is the attackNPC method in my CombatController,
Code:
public void attackNPC(int victim, Player player) { // Handles PVN.
if (!NPCManager.isValid(victim)) {
sender.sendMessage("You cannot attack this NPC.");
return;
}
NPC n = NPCManager.getNPC(victim);
player.setAttackingNPC(n);
sender.sendMessage("You attack a NPC with an ID of: " + victim);
player.setEntityFace(victim);
if (n.isMoveable())
n.setMoveable(false);
}
I do not see any problems with the code, however when I attack an NPC, I get a NullPointerException. The FIRST line that the error comes up is the line - Combat.attackNPC(victim, player);.
Please help me! I have no idea and this is delaying me from continuing with my combat!
Thanks a lot in advance!
-Deadly Uzi