Base: PI - Project-Insanity
Problem: I want the spawned NPC to follow my player without being in combat.
Errors(Compiling Errors): None
Other Information/Media(Pictures, etc):
This is my spawning method.
Code:
/**
* Summon npc, barrows, etc
**/
public void spawnNpc(Client c, int npcType, int x, int y, int heightLevel, int WalkingType, int HP, int maxHit, int attack, int defence, boolean attackPlayer, boolean headIcon, int spawnedBy) {
// 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();;
if(headIcon)
c.getPA().drawHeadicon(1, slot, 0, 0);
if(attackPlayer) {
newNPC.underAttack = true;
if(c != null) {
if
(server.model.minigames.Barrows.COFFIN_AND_BROTHERS[c.randomCoffin][1] != newNPC.npcType) {
if(newNPC.npcType == 2025 || newNPC.npcType == 2026 || newNPC.npcType == 2027 ||
newNPC.npcType == 2028 || newNPC.npcType == 2029 || newNPC.npcType == 2030) {
newNPC.forceChat("You dare disturb my rest!");
}
}
if(server.model.minigames.Barrows.COFFIN_AND_BROTHERS[c.randomCoffin][1] == newNPC.npcType) {
newNPC.forceChat("You dare steal from us!");
}
newNPC.killerId = c.playerId;
}
}
npcs[slot] = newNPC;
}