I had this working before, I don't know what I did but now its all messed up
Video:
spawnNpc3 void:
Code:
public void spawnNpc3(Client c, int npcType, int x, int y, int heightLevel, int WalkingType, int HP, int maxHit, int attack, int defence, boolean attackPlayer, boolean headIcon, boolean summonFollow) {
// 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) {
//Misc.println("No Free Slot");
return; // no free slot found
}
NPC newNPC = new NPC(slot, npcType);
newNPC.absX = x;
newNPC.absY = y;
newNPC.makeX = x;
newNPC.makeY = y;
newNPC.heightLevel = heightLevel;
newNPC.walkingType = WalkingType;
newNPC.HP = HP;
newNPC.MaxHP = HP;
newNPC.maxHit = maxHit;
newNPC.attack = attack;
newNPC.defence = defence;
newNPC.spawnedBy = c.getId();
newNPC.underAttack = true;
newNPC.facePlayer(c.playerId);
if(headIcon)
c.getPA().drawHeadicon(1, slot, 0, 0);
if (summonFollow) {
newNPC.summoner = true;
newNPC.summonedBy = c.playerId;
c.summonId = npcType;
c.hasNpc = true;
}
if(attackPlayer) {
newNPC.underAttack = true;
if(c != null) {
newNPC.killerId = c.playerId;
}
}
npcs[slot] = newNPC;
}
Followplayer void:
Code:
public void followPlayer(int i, int playerId) {
if (Server.playerHandler.players[playerId] == null) {
return;
}
if (Server.playerHandler.players[playerId].respawnTimer > 0) {
npcs[i].facePlayer(0);
npcs[i].randomWalk = true;
npcs[i].underAttack = false;
return;
}
if (!followPlayer(i)) {
npcs[i].facePlayer(playerId);
return;
}
int playerX = Server.playerHandler.players[playerId].absX;
int playerY = Server.playerHandler.players[playerId].absY;
npcs[i].randomWalk = false;
if (goodDistance(npcs[i].getX(), npcs[i].getY(), playerX, playerY, distanceRequired(i)))
return;
if((npcs[i].spawnedBy > 0) || ((npcs[i].absX < npcs[i].makeX + Config.NPC_FOLLOW_DISTANCE) && (npcs[i].absX > npcs[i].makeX - Config.NPC_FOLLOW_DISTANCE) && (npcs[i].absY < npcs[i].makeY + Config.NPC_FOLLOW_DISTANCE) && (npcs[i].absY > npcs[i].makeY - Config.NPC_FOLLOW_DISTANCE))) {
if(npcs[i].heightLevel == Server.playerHandler.players[playerId].heightLevel) {
if(Server.playerHandler.players[playerId] != null && npcs[i] != null) {
if(playerY < npcs[i].absY) {
npcs[i].moveX = GetMove(npcs[i].absX, playerX);
npcs[i].moveY = GetMove(npcs[i].absY, playerY);
} else if(playerY > npcs[i].absY) {
npcs[i].moveX = GetMove(npcs[i].absX, playerX);
npcs[i].moveY = GetMove(npcs[i].absY, playerY);
} else if(playerX < npcs[i].absX) {
npcs[i].moveX = GetMove(npcs[i].absX, playerX);
npcs[i].moveY = GetMove(npcs[i].absY, playerY);
} else if(playerX > npcs[i].absX) {
npcs[i].moveX = GetMove(npcs[i].absX, playerX);
npcs[i].moveY = GetMove(npcs[i].absY, playerY);
} else if(playerX == npcs[i].absX || playerY == npcs[i].absY) {
int o = Misc.random(3);
switch(o) {
case 0:
npcs[i].moveX = GetMove(npcs[i].absX, playerX);
npcs[i].moveY = GetMove(npcs[i].absY, playerY+1);
break;
case 1:
npcs[i].moveX = GetMove(npcs[i].absX, playerX);
npcs[i].moveY = GetMove(npcs[i].absY, playerY-1);
break;
case 2:
npcs[i].moveX = GetMove(npcs[i].absX, playerX+1);
npcs[i].moveY = GetMove(npcs[i].absY, playerY);
break;
case 3:
npcs[i].moveX = GetMove(npcs[i].absX, playerX-1);
npcs[i].moveY = GetMove(npcs[i].absY, playerY);
break;
}
}
int x = (npcs[i].absX + npcs[i].moveX);
int y = (npcs[i].absY + npcs[i].moveY);
npcs[i].facePlayer(playerId);
if (checkClipping(i))
npcs[i].getNextNPCMovement(i);
else {
npcs[i].moveX = 0;
npcs[i].moveY = 0;
}
npcs[i].facePlayer(playerId);
npcs[i].updateRequired = true;
}
}
} else {
npcs[i].facePlayer(0);
npcs[i].randomWalk = true;
npcs[i].underAttack = false;
}
}
How I call them both:
When you click "Summon" on the pouch
Code:
if(itemId == 15053) {
if (!c.hasNpc) {
c.sendMessage("You summon you're Spirit Terror Bird.");
Server.npcHandler.spawnNpc3(c, 3589, c.absX, c.absY-1, c.heightLevel, 0, 120, 25, 200, 200, true, false, true);
c.getItems().deleteItem(15053, 1);
c.getPA().followPlayer(c.playerIndex);
c.hasNpc = true;
} else
return;
}