The attachment preview is chopped off after the first 10 KB. Please download the entire file.

```
import java.io.*;
public class NPCHandler {
public void newPetNPC(int npcType, int x, int y, int heightLevel, int rangex1, int rangey1, int rangex2, int rangey2, int WalkingType, int HP, boolean Respawns, int summonedBy) {
int slot = -1;
for (int i = 1; i < maxNPCs; i++) {
if (npcs[i] == null) {
slot = i;
break;
}
}
if(slot == -1)
return;
if(HP <= 0) {
HP = 100;
}
int Timer = 60; // about 30 seconds
int teleportTimer = -1;
if(teleportTimer >= 0) {
teleportTimer -= 1;
}
if(teleportTimer == -1) {
teleportTimer = Timer;
}
if(teleportTimer == 0) {
NPC newNPC = new NPC(slot, npcType);
newNPC.absX = summonedBy;
newNPC.absY = summonedBy;
newNPC.makeX = summonedBy;
newNPC.makeY = summonedBy;
newNPC.moverangeX1 = rangex1;
newNPC.moverangeY1 = rangey1;
newNPC.moverangeX2 = rangex2;
newNPC.moverangeY2 = rangey2;
newNPC.walkingType = WalkingType;
newNPC.HP = HP;
newNPC.MaxHP = HP;
newNPC.heightLevel = heightLevel;
newNPC.Respawns = Respawns;
newNPC.followPlayer = summonedBy;
newNPC.followingPlayer = true;
}
NPC newNPC = new NPC(slot, npcType);
newNPC.absX = x;
newNPC.absY = y;
newNPC.makeX = x;
newNPC.makeY = y;
newNPC.moverangeX1 = rangex1;
newNPC.moverangeY1 = rangey1;
newNPC.moverangeX2 = rangex2;
newNPC.moverangeY2 = rangey2;
newNPC.walkingType = WalkingType;
newNPC.HP = HP;
newNPC.MaxHP = HP;
newNPC.heightLevel = heightLevel;
newNPC.Respawns = Respawns;
newNPC.followPlayer = summonedBy;
newNPC.followingPlayer = true;
npcs[slot] = newNPC;
}
public static int maxNPCs = 10000;
public static int maxListedNPCs = 10000;
public static int maxNPCDrops = 10000;
public NPC npcs[] = new NPC[maxNPCs];
public NPCList NpcList[] = new NPCList[maxListedNPCs];
public NPCDrops NpcDrops[] = new NPCDrops[maxNPCDrops];
NPCHandler() {
for (int i = 0; i < maxNPCs; i++) {
npcs[i] = null;
}
for (int i = 0; i < maxListedNPCs; i++) {
NpcList[i] = null;
}
for (int i = 0; i < maxNPCDrops; i++) {
NpcDrops[i] = null;
}
loadNPCList("npc.cfg");
loadNPCDrops("npcdrops.cfg");
loadAutoSpawn("autospawn.cfg");
}
public void newNPC(int npcType, int x, int y, int heightLevel, int rangex1, int rangey1, int rangex2, int rangey2, int WalkingType, int HP, boolean Respawns) {
// first, search for a free slot
int slot = -1;
for (int i = 1; i < maxNPCs; i++) {
if (npcs[i] == null) {
slot = i;
break;
}
}
if (slot == -1) {
return;
} // no free slot found
if (HP <= 0) { // This will cause client crashes if we don't use this :) - xero
HP = 3000;
}
NPC newNPC = new NPC(slot, npcType);
newNPC.absX = x;
newNPC.absY = y;
newNPC.makeX = x;
newNPC.makeY = y;
newNPC.moverangeX1 = rangex1;
newNPC.moverangeY1 = rangey1;
newNPC.moverangeX2 = rangex2;
newNPC.moverangeY2 = rangey2;
newNPC.walkingType = WalkingType;
newNPC.HP = HP;
newNPC.MaxHP = HP;
newNPC.MaxHit = (int) Math.floor((HP / 100));
if (newNPC.MaxHit < 1) {
newNPC.MaxHit = 1;
}
newNPC.heightLevel = heightLevel;
newNPC.Respawns = Respawns;
npcs[slot] = newNPC;
}
public void newSummonedNPC(int npcType, int x, int y, int heightLevel, int rangex1, int rangey1, int rangex2, int rangey2, int WalkingType, int HP, boolean Respawns, int summonedBy) {
// first, search for a free slot
int slot = -1;
for (int i = 1; i < maxNPCs; i++) {
if (npcs[i] == null) {
slot = i;
break;
}
}
if (slot == -1) {
return;
} // no free slot found
if (HP <= 0) { // This will cause client crashes if we don't use this :) - xero
HP = 3000;
}
NPC newNPC = new NPC(slot, npcType);
newNPC.absX = x;
newNPC.absY = y;
newNPC.makeX = x;
newNPC.makeY = y;
newNPC.moverangeX1 = rangex1;
newNPC.moverangeY1 = rangey1;
newNPC.moverangeX2 = rangex2;
newNPC.moverangeY2 = rangey2;
newNPC.walkingType = WalkingType;
newNPC.HP = HP;
newNPC.MaxHP = HP;
newNPC.MaxHit = (int) Math.floor((HP / 100));
if (newNPC.MaxHit < 1) {
newNPC.MaxHit = 10;
}
newNPC.heightLevel = heightLevel;
newNPC.Respawns = Respawns;
newNPC.followPlayer = summonedBy;
newNPC.followingPlayer = true;
npcs[slot] = newNPC;
}
public void newNPCList(int npcType, String npcName, int combat, int HP) {
// first, search for a free slot
int slot = -1;
for (int i = 0; i < maxListedNPCs; i++) {
if (NpcList[i] == null) {
slot = i;
break;
}
}
if (slot == -1) {
return;
} // no free slot found
NPCList newNPCList = new NPCList(npcType);
newNPCList.npcName = npcName;
newNPCList.npcCombat = combat;
newNPCList.npcHealth = HP;
NpcList[slot] = newNPCList;
}
public void newNPCDrop(int npcType, int dropType, int Items[], int ItemsN[]) {
// first, search for a free slot
int slot = -1;
for (int i = 0; i < maxNPCDrops; i++) {
if (NpcDrops[i] == null) {
slot = i;
break;
}
}
if (slot == -1) {
return;
} // no free slot found
NPCDrops newNPCDrop = new NPCDrops(npcType);
newNPCDrop.DropType = dropType;
newNPCDrop.Items = Items;
newNPCDrop.ItemsN = ItemsN;
NpcDrops[slot] = newNPCDrop;
}
/*
public boolean IsInWorldMap(int coordX, int coordY) {
for (int i = 0; i < worldmap[0].length; i++) {
//if (worldmap[0][i] == coordX && worldmap[1][i] == coordY) {
return true;
//}
}
return false;
}
public boolean IsInWorldMap2(int coordX, int coordY) {
for (int i = 0; i < worldmap2[0].length; i++) {
if (worldmap2[0][i] == coordX && worldmap2[1][i] == coordY) {
return true;
}
}
return true;
}
public boolean IsInRange(int NPCID, int MoveX, int MoveY) {
int NewMoveX = (npcs[NPCID].absX + MoveX);
int NewMoveY = (npcs[NPCID].absY + MoveY);
if (NewMoveX <= npcs[NPCID].moverangeX1 && NewMoveX >= npcs[NPCID].moverangeX2 && NewMoveY <= npcs[NPCID].moverangeY1 && NewMoveY >= npcs[NPCID].moverangeY2) {
if ((npcs[NPCID].walkingType == 1 && IsInWorldMap(NewMoveX, NewMoveY) == true) || (npcs[NPCID].walkingType == 2 && IsInWorldMap2(NewMoveX, NewMoveY) == false)) {
if (MoveX == MoveY) {
if ((IsInWorldMap(NewMoveX, npcs[NPCID].absY) == true && IsInWorldMap(npcs[NPCID].absX, NewMoveY) == true) || (IsInWorldMap2(NewMoveX, npcs[NPCID].absY) == false && IsInWorldMap2(npcs[NPCID].absX, NewMoveY) == false)) {
return true;
}
return false;
}
return true;
}
}
return false;
}*/
public int GetMove(int Place1, int Place2) { // Thanks to diablo for this! Fixed my npc follow code <3
if ((Place1 - Place2) == 0) {
return 0;
} else if ((Place1 - Place2) < 0) {
return 1;
} else if ((Place1 - Place2) > 0) {
return -1;
}
return 0;
}
public void FollowPlayer(int NPCID) {
int follow = npcs[NPCID].followPlayer;
int playerX = server.playerHandler.players[follow].absX;
int playerY = server.playerHandler.players[follow].absY;
npcs[NPCID].RandomWalk = false;
if (server.playerHandler.players[follow] != null) {
if (playerY < npcs[NPCID].absY) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY + 1);
} else if (playerY > npcs[NPCID].absY) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY - 1);
} else if (playerX < npcs[NPCID].absX) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX + 1);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY);
} else if (playerX > npcs[NPCID].absX) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX - 1);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY);
}
npcs[NPCID].getNextNPCMovement();
npcs[NPCID].updateRequired = true;
}
}
public void FollowPlayerCB(int NPCID, int playerID) {
int playerX = server.playerHandler.players[playerID].absX;
int playerY = server.playerHandler.players[playerID].absY;
npcs[NPCID].RandomWalk = false;
if (server.playerHandler.players[playerID] != null) {
if (playerY < npcs[NPCID].absY) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY + 1);
} else if (playerY > npcs[NPCID].absY) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY - 1);
} else if (playerX < npcs[NPCID].absX) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX + 1);
npcs[NPCID].moveY = GetMove(npcs[NPCID].absY, playerY);
} else if (playerX > npcs[NPCID].absX) {
npcs[NPCID].moveX = GetMove(npcs[NPCID].absX, playerX - 1);
npcs[NPCID].moveY
```