Evolution Server
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Evolution Server

This is the official site of Evolution!!!
 
HomeHome  PortalPortal  SearchSearch  Latest imagesLatest images  RegisterRegister  Log inLog in  

 

 TUT: How to make npcs drop stuff

Go down 
AuthorMessage
nightleaf
Admin
Admin
nightleaf


Posts : 112
Join date : 2007-08-05
Age : 32
Location : In Evolution

Members
Nightscape 2: = Dead! Evolution Server!!!

TUT: How to make npcs drop stuff Empty
PostSubject: TUT: How to make npcs drop stuff   TUT: How to make npcs drop stuff Icon_minitimeTue Sep 04, 2007 9:36 am

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)
Back to top Go down
https://evolutionserver.forumotion.com
 
TUT: How to make npcs drop stuff
Back to top 
Page 1 of 1
 Similar topics
-
» New Map?

Permissions in this forum:You cannot reply to topics in this forum
Evolution Server :: Server Coding-
Jump to: