PDA

View Full Version : [508] NPC Dropping system.



Sebo
July 20th, 2010, 03:40
Hello everybody.

This is the first thing i'm ever releasing on this forum, so I hope I can get *some* positive comments back on this. So, no anti-leech on this.

This can be used in any sauce if you just modify a few things. So don't ask me to rewrite it for your shitty bulby shit.

First off, create a new class and name it "NPCDrops" in the palidino76.rs2.npcs.combat package.

Second, add this stuff in there:


package palidino76.rs2.npcs.combat;

import palidino76.rs2.Engine;
import palidino76.rs2.npcs.NPC;
import palidino76.rs2.players.Player;
import palidino76.rs2.util.Misc;

public class NPCDrops {

public static void doDrop(Player pa, NPC n) {
switch (n.npcType) {
case 1: // Man
if (Misc.random(3) == 1)
Engine.items.createGroundItem(995, 20 + Misc.random(1200), n.absX, n.absY, n.heightLevel, pa.username);

Engine.items.createGroundItem(526, 1, n.absX, n.absY, n.heightLevel, pa.username); //Bones
break;
}
}
}


Now, save and close that mofo up.

Now, open up your NPCPlayerCombat class, and scroll all the way down until you see:


if (n.isDead)
{
n.attackingPlayer = false;


after that, add this:


n.dropItemsOnDeath(p, n);

Save that file, and I think you are good to go! I might have missed something though, not sure.

To add a new NPC to drop shit, go to the NPCDrop class, and add:



case NPCIDHERE:
// if you want the random drop chance add this, and change the
// "2" to a higher number if you want the drop to be rarer.
// if (Misc.random(2) == 1) {
// The dropped item here
// }
break;


enjoy.

Dodge'
July 22nd, 2010, 15:24
or just go into npcdrops.cfg...

SiniSoul
July 22nd, 2010, 16:24
WTF was the point of this xD

halolouie
June 18th, 2011, 20:34
Not gonna lie. This method is probably the most inefficient method ever. LOL. I just created drop tables of possible items and based the rarity of the drop along with the quantity on the combat level and name of the monster. IE. Monsters that contain "demon" have gem tables, herb tables, rare tables, default tables, ash drop, and charm drops all based on the combat level. The higher the level the more likely a better drop and possibility of that drop. I handled general drops for all npcs in about 200 lines of code. With the only ram usage is the byte 0-255 saved in an arraylist for each npcType in NPCList and only lookups for cpu usage. In about 20 minutes time all npcs excluding specific dropping monsters such as Jad, Corp, ect. had been handled with ring of wealth having effect for all. :) Get ownd lol jk

Mofo
June 18th, 2011, 23:34
npcdrops.cfg = best

There was no point of this, but gj writing it up :P

ryan bro
November 27th, 2011, 14:38
if your npc's dont drop items then go to npchandler.java and change the '7700' to '10000' save compile :)