Thread: NPC drops with Java file

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 NPC drops with Java file 
    Banned

    Join Date
    Mar 2008
    Posts
    2,595
    Thanks given
    128
    Thanks received
    191
    Rep Power
    0
    I know there's bound to be an error because I made this like 1 month ago, and I feel like I'm forgetting something. So if you have any problems adding just tell me.

    Description: Make your NPC drop things with a java file, instead of cfg, or instead of crappy czar version.

    Difficulty: 2/10

    Assumed Knowledge: Copy and Paste, How to remove stuff

    Tested Server: Devolution v7

    Files/Classes Modified: server.java, NPCDrops.java, NPCHandler.java, client.java

    Procedure

    Step 1: MAKE A FRICKEN BACKUP. Then delete ANYTHING to do with NPCDrops including the NPCDrops class, and if you have it, the npc drops cfg file!

    Step 2: In server.java, if you haven't already, declare:

    Code:
    public static NPCDrops NPCDrops = new NPCDrops();
    Step 3: Now in client.java in the method 'initialize' add this at the top:

    Code:
    server.npcHandler.plazID = playerId;
    (I used a playerId on purpose. Not public client c or something.)

    Step 4: Open up NPCHandler.java

    Declare:

    Code:
    public int plazID = -1;
    By now, you have deleted anything to do with drops in the NPCHandler too. Search for this:

    Code:
    					} else if ((npcs[i].actionTimer == 0)
    							&& (npcs[i].DeadApply == true)
    							&& (npcs[i].NeedRespawn == false)
    							&& (npcs[i] != null)) {
    Add this:

    Code:
    server.NPCDrops.main(npcs[i].npcType, plazID, npcs[i].absX, npcs[i].absY);
    In this area (look at where I added at bottom):

    Code:
    						if ((temp != null) && !temp.disconnected) {
    							if (npcs[i].npcType == 936) {
    								server.playerHandler
    										.yell("San Tojalon has been slain by "
    												+ temp.playerName + " (level-"
    												+ temp.combatLevel + ")");
    							} else if (npcs[i].npcType == 221) {
    								server.playerHandler
    										.yell("The Black Knight Titan has been slain by "
    												+ temp.playerName
    												+ " (level-"
    												+ temp.combatLevel + ")");
    							} else if (npcs[i].npcType == 1613) {
    								server.playerHandler
    										.yell("Nechryael has been slain by "
    												+ temp.playerName + " (level-"
    												+ temp.combatLevel + ")");
    							} else if (npcs[i].npcType == 1158) {
    								temp.SummonNewNPC(1160);
    							}
    							server.NPCDrops.main(npcs[i].npcType, plazID, npcs[i].absX, npcs[i].absY);
    							temp.attackedNpc = false;
    							temp.attackedNpcId = -1;
    						}
    I added it there, see.

    Step 5: Replace your NPCDrops.java (if you don't have, just add this class):

    Code:
    /*
     * Npc Drops
     * Made by Filth
     */
    
    public class NPCDrops {
    
    	public int dropAmount = -1;
    	public int drops = -1;
    	public int drop[] = new int[15];
    	public int amount[] = new int[15];
    	public boolean used[] = new boolean[15];
    
    	public void main(int thanpc, int thaplr, int npcX, int npcY) {
    		dropAmount = -1;
    		drops = -1;
    		for (int x = 0; x < 15; x++) {
    			used[x] = false;
    			drop[x] = -1;
    			amount[x] = 1;
    		}
    		client c = (client) server.playerHandler.players[thaplr];
    		if (c != null) {
    			switch(thanpc) {
    
    			/* HERES WHERE YOU PUT NPC DROPS
    				SAY CASE (NPCID): THEN PUT
    					THE DROPS YOU WANT */
    
    				case 7:
    				/* Farmer - Level 7 */
    					if (chance(87)) {
    						drop[0] = 995;
    						amount[0] = misc.random(324);
    						//drop[1] = server.Clues.dropClue(1);
    					}
    					break;
    
    				case 35:
    				/* Soldier - Level 28 */
    					if (chance(68)) {
    						drop[0] = 995;
    						amount[0] = misc.random(1394);
    					//} else if (chance(3)) { you don't have clues :p
    						//drop[0] = server.Clues.dropClue(1);
    					}
    					break;
    			}
    			drops = 0;
    			Bones(thanpc, thaplr);
    			for (int y = 0; y < 15; y++) {
    				if (drop[y] > -1 && dropAmount == -1) {
    					if (amount[y] <= 0) {
    						amount[y] = 1;
    					}
    					ItemHandler.addItem(drop[y], npcX, npcY, amount[y], thaplr, false);
    				} else if (dropAmount != -1) {
    					if (drops < dropAmount) {
    						DropRandoms(thaplr);
    						drops++;
    					}
    				}
    			}
    		}
    	}
    
    	public void DropRandoms(int thaplr) {
    		int random = misc.random(15);
    		if (drop[random] > -1 && used[random] == false) {
    			used[random] = true;
    			ItemHandler.addItem(drop[random], npcX, npcY, amount[random], thaplr, false);
    		} else {
    			loop(thaplr);
    		}
    	}
    
    	public void loop(int thaplr) {
    		DropRandoms(thaplr);
    	}
    
    	public void Bones(int NPC, int plr) {
    		if (NPC == 3200) {
    		} else {
    			ItemHandler.addItem(526, npcX, npcY, 1, plr, false);
    		}
    	}
    
    	public boolean chance(int percent) {
    	if (percent > 100) {
    		percent = 100;
    	}
    	int prob = misc.random(100);
    		for (int x = 0; x < percent; x++) {
    			if (x == prob) {
    				return true;
    			}
    		}
    	return false;
    	}
    }
    HOW TO USE:

    In the switch of 'thanpc' put the npc id, then put what it drops.

    Here's how you drop:

    Code:
    drop[0] = ITEMID;
    amount[0] = AMOUNT (DEFAULT IS 1, SO YOU DON'T ALWAYS HAVE TO ADD);
    That will drop 1 item, which you choose amount of. So here's an example of an NPC dropping 1 item:

    Code:
    case 1:
    drop[0] = 995;
    amount[0] = misc.random(500);
    break;
    This npc with the id of '1' will drop a random amount of gold. (It will NOT drop 0 gold. If the random amount turns out to be 0, it will make it 1) In this case, it will ALWAYS drop gold.

    If you want to change the percent of drop add:

    Code:
    case 1:
    if (chance(80)) {
    drop[0] = 995;
    amount[0] = misc.random(500);
    }
    break;
    Now it will dorp a random amount of gold 80% of the time.

    If you want it drop more than 1 item make it:

    Code:
    case 1:
    drop[0] = 995;
    amount[0] = misc.random(500);
    drop[1] = 1000;
    break;
    Now it will drop both gold, and the item '1000' 100% of the time. Since you didn't put the amount of the item '1000', it will drop 1 of it.

    If you want it to only drop ONE of these items, put:

    Code:
    case 1:
    drop[0] = 995;
    amount[0] = misc.random(500);
    drop[1] = 1000;
    dropAmount = 1;
    break;
    Now the drop amount is '1', which means its going to drop 1 item at random.

    Reason I made it a class instead of a cfg, is so you can do things like:

    Code:
    case 1:
    if (questLevel == 1) {
    drop[0] = 995;
    amount[0] = misc.random(500);
    }
    break;
    For example, if you're getting keys from a rat for the Demon Slayer quest, you don't want someone to keep getting keys, so you'd put:

    Code:
    case 1:
    if (!playerHasKey(KEY)) {
    if (chance(20)) {
    drop[0] = KEY;
    }
    }
    break;
    And you want to change method bones to drop correct bones.
    Reply With Quote  
     

  2. #2  
    Registered Member
    minutes's Avatar
    Join Date
    Apr 2008
    Posts
    1,926
    Thanks given
    2
    Thanks received
    19
    Rep Power
    465
    VERY NICE!

    i maybe use this =)



    click banner to join gtracer!
    Reply With Quote  
     

  3. #3  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    hi this is very nice i use it really like it:O


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    You missed some conventions, also i could be done with a other way
    but you tried at least
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Mar 2008
    Posts
    2,595
    Thanks given
    128
    Thanks received
    191
    Rep Power
    0
    Quote Originally Posted by Jonas++ View Post
    You missed some conventions, also i could be done with a other way
    but you tried at least
    Damn your conventions, like I care.

    And what other way would effect the outcome/possibly make this any easier that you can't already do by editing this in 1 min?
    Reply With Quote  
     

  6. #6  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    You missed some conventions, also i could be done with a other way
    but you tried at least
    dude it is perfekt as it is you are just jealous


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Mar 2008
    Posts
    2,595
    Thanks given
    128
    Thanks received
    191
    Rep Power
    0
    Srsly Jonas I'd like to see what I did wrong.
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Mar 2008
    Posts
    2,595
    Thanks given
    128
    Thanks received
    191
    Rep Power
    0
    And of course, Jonas doesn't have anything to say.
    Reply With Quote  
     

  9. #9  
    Previously Hyperion


    Join Date
    Jan 2009
    Posts
    1,254
    Thanks given
    3
    Thanks received
    18
    Rep Power
    138
    Never had an error like that. I got everything added correctly to my knowledge
    Code:
    server.java:45: cannot find symbol
    symbol  : constructor NPCDrops()
    location: class NPCDrops
            public static NPCDrops NPCDrops = new NPCDrops();
                                              ^
    Note: EconomyReset.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    1 error
    Press any key to continue . . .
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Jun 2007
    Age
    29
    Posts
    3,003
    Thanks given
    52
    Thanks received
    98
    Rep Power
    3208
    filth you still check this thread?
    I'am using Devolution V7..

    Code:
    NPCDrops.java:70: cannot find symbol
    symbol  : variable npcX
    location: class NPCDrops
                            ItemHandler.addItem(dro
    dom], thaplr, false);
    
    NPCDrops.java:70: cannot find symbol
    symbol  : variable npcY
    location: class NPCDrops
                            ItemHandler.addItem(dro
    dom], thaplr, false);
    
    NPCDrops.java:83: cannot find symbol
    symbol  : variable npcX
    location: class NPCDrops
                            ItemHandler.addItem(526
    
    NPCDrops.java:83: cannot find symbol
    symbol  : variable npcY
    location: class NPCDrops
                            ItemHandler.addItem(526
    
    NPCHandler.java:968: cannot find symbol
    symbol  : variable npcId
    location: class NPCDrops
                                    if ((NpcDrops[i
    
    NPCHandler.java:969: cannot find symbol
    symbol  : variable DropType
    location: class NPCDrops
    
    Type)) {
    
    NPCHandler.java:1406: cannot find symbol
    symbol  : constructor NPCDrops(int)
    location: class NPCDrops
                    NPCDrops newNPCDrop = new NPCDr
                                          ^
    NPCHandler.java:1407: cannot find symbol
    symbol  : variable DropType
    location: class NPCDrops
                    newNPCDrop.DropType = dropType;
                              ^
    NPCHandler.java:1408: cannot find symbol
    symbol  : variable Items
    location: class NPCDrops
                    newNPCDrop.Items = Items;
                              ^
    NPCHandler.java:1409: cannot find symbol
    symbol  : variable ItemsN
    location: class NPCDrops
                    newNPCDrop.ItemsN = ItemsN;
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •