Purpose: To teach how to make NPC's drop items.
First off open up your NPCHandler.java and search for this.
Code:
- Code:
-
if(npcs[NPCID].npcType ==
Now scroll all the way down until at the end you see
Code:
- Code:
-
}
}
Press enter after the first one and add this.
Code:
- Code:
-
if(npcs[NPCID].npcType == NPC-ID-HERE{
ItemHandler.addItem(ITEM-ID-HERE,npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller(NPCID), false);
}
Now were it says "NPC-ID-HERE" that is were you will add the ID of the NPC you want.
Were is says "ITEM-ID-HERE" that is were you will add the item you want the NPC to drop.
Now save and close the NPCHandler.java
Open up your Item2.java
Scroll all the way to the bottom until you see this.
Code:
- Code:
-
}
}
Press enter after the first "}" and add this.
Code:
- Code:
-
public static int OBJECT-NAME-HERE[]= {ITEM-ID-HERE};
public static int randomOBJECT-NAME-HERE()
{
return OBJECT-NAME-HERE[(int)(Math.random()*OBJECT-NAME-HERE.length)];
}
So say if i wanted the item to be an infinity top it would look like this.
Code:
- Code:
-
public static int Infinity_Top[] = {6916};
public static int randomInfinity_Top()
{
return Infinity_Top[(int)(Math.random()*Infinity_Top.length)];
}
You can also add more into were you add the Item ID in Item2.java to make drops more rarer. (Not to sure how to do that so I didnt add sorry)