Eldrazi
Eater of Worlds
Uhm.. Lemme try to give you an example in psuedo code:that sounds confusing
Code:
/// HEAD
public override void AI
{
if(npc.ai[0] == 0)
{
int npcToFollow = npc.whoAmI;
for(int i = 0; i < 10; ++i)
{
int newNPC;
if(i < 9)
newNPC = NPC.NewNPC(npc.position.X, npc.position.Y, mod.NPCType("BodyPart");
else
newNPC = NPC.NewNPC(npc.position.X, npc.position.Y, mod.NPCType("TailPart"); // We only want one tail.
Main.npc[newNPC].ai[0] = npcToFollow;
npcToFollow = newNPC;
}
npc.ai[0] = 1; // Can only be triggered once
}
// Direction and moving code.
}
// TAIL & BODY
public override void AI
{
NPC target = Main.npc[(int)npc.ai[0]];
// Now we have the part that was spawned (quite litterally) before this one, so we'll be able to follow it.
}