Purpose: To teach you about NPC's
Difficulty: Ranging from 1/10 to 3/10
Classes modified: Client.java, npc.cfg, autospawn.cfg, npchandler.java
CODE
This guide was written by Sacred of Silabsoft/runelocus/RSPS tutorial forums AKA 00xo0x of Rune-server forums, it is NOT to be used by any individual without his permission.
Table of content:
I. Intro
II. Spawning NPC's
III. Editing an NPC's health
IV. Making an NPC shout something
V. Adding NPC dialogue
VI. Changing an NPC's max hit, attack animation.
VII. Making an NPC teleport you apon death
VIII. How to give an NPC drops
IX. Credits
I. Hello all. This is my guide to NPC's, i spent ALOT more time writing it then you did viewing it, so please leave a comment
II. You can give an NPC and effect, you make an NPC part of your minigame, but without spawning the NPC itself, you can't do anything!
So basically, open up your autospawn.cfg. There you should see spawning codes, now, to add a new NPC, use this format.
CODE
spawn = ### XXXX YYYY 0 0 0 0 0 1 Description
####'s = The npc ID
XXXX = The x coordinate of the NPC you want to add
YYYY= The y coordinate of the NPC you want to add
0 0 0 0 0 1 = The 0's are the heightlevel and the rangex and y's (recommend to leave blank) and the 1 is the walking type, leave it at one too.
Description = Put anything here, maybe the name of the npc or whatever you want.
Now, if you want to add a heightlevel to the NPC (Make it underground or upstairs) then you would either add this before the walking type:
CODE
- 1 = Minus 1 height
1 = plus 1 height
III. So, is there a monster that is too hard/too easy to defeat? well , you can fix that!
Open up npc.cfg, there you should see:
CODE
//----NpcID-----NpcName-------------------------combat--health
Underneath that, add this code:
CODE
npc = $$$ @@@@ * %
(Don't create any extra space between the digits)
$$$'s = The Id of the monster.
@@@@'s = The name of the monster (doesn't matter )
* = The monsters combat, just leave it at the monsters natural level
% = The monsters health, you can change it to whatever suits you.
IV. Now then, we are going to make an NPC announce something so you don't have to sit there and advertise it yourself (Beware, npc overhead text creates lag! so don't add too much)
Open up npchandler.java, and search for:
CODE
npcs.RandomWalk == true) {
Underneath, you should see NPC overhead text codes. To make a new one, add this code in underneath:
CODE
(npcs.RandomWalk == true) {
CODE
if (npcs.npcType == ^^^^) {
if (misc.random2(30) <= 2) {
npcs.updateRequired = true;
npcs.textUpdateRequired = true;
npcs.textUpdate = "EDIT YOUR TEXT HERE!";
}
}
^^^^'s = The NPC id that is supposed to shout out the text
EDIT YOUR TEXT HERE = The text, self explanatory (note, don't delete the two "")
You can initially change:
CODE
if (misc.random2(30) <= 2)
That's only if you want to change the rate that the npc talks at (faster, slower)
V. Now, here is where it gets slightly more challenging. Creating NPC dialogue. What is npc dialogue?, you may ask. Npc dialogue is basically a chat you have with an NPC.
Open up client.java.
Now, first off, we need to make the chat itself.
Search for:
CODE
public void UpdateNPCChat() {
Underneath it, you should see a few cases. Now, to add our dialogue, we need to use this format:
CODE
case ****:
sendFrame126(GetNpcName(NpcTalkTo), 4902);
sendFrame126("YOUR TEXT HERE", 4903);
sendFrame126("YOUR TEXT HERE", 4904);
sendFrame126("YOUR TEXT HERE", 4905);
sendFrame126("YOUR TEXT HERE", 4906);
sendFrame75(NpcTalkTo, 4901);
sendFrame164(4900);
NpcDialogueSend = true;
break;
Now to explain it.
case **** = The case number, it doesn't matter which case, it could be case 734 or case 666 or case 1000, it doesn't matter! (just make sure the case isn't already in use)
YOUR TEXT HERE = the text that will appear once you talk to the NPC
sendFrame126(GetNpcName(NpcTalkTo), 4902); = The npc's name, leave it as it is
Ok, now that we have that added, we need to make the NPC say the dialogue when we talk to them.
Search for:
CODE
case 155:
This is our first click NPC void (meaning the first option on an NPC). Now , to make the npc use the case of dialogue when we use first click, we need to add in using this format:
CODE
if (NPCID == @@@@) {
skillX = server.npcHandler.npcs[NPCSlot].absX;
skillY = server.npcHandler.npcs[NPCSlot].absY;
NpcWanneTalk = ^^^^;
}
@@@@'s = the ID of the npc that will initiate the case of dialogue
^^^^'s = The dialogue case (The one you added before)
Congratualations! Now you have your dialogue set up.
Now that we have our dialogue, we need to decide on a few things.
1. Do you want to continue the dialogue?
2. Do you want to end the dialogue?
Option 1:
Make a new case of dialogue using the same format as above. But this time, make the case 1 number higher then the one it will continue on to. So for example, if your dialogue case was 77, we'd make the new case 78, and if it was 90, we'd make it 91 ect.
Once you have your dialogue search for:
CODE
case 40:
Until you see things like:
CODE
if (NpcDialogue == ID's ||..
Now, add the case of your dialogue you want to continue (in the upper half of the case), using this format:
CODE
NpcDialogue == $$$$ ||
$$$$'s = The dialogue case (The one you added before)
NpcDialogue += 1; = This means that the case of dialogue will go up one more (This is why you wanted to add the case 1 more). So for example, we add the case 666,this would make it, so when we click "continue" it would go to case 667.
And there you go! you can make your dialogue continue as many times as you want , so go ahead!
Option 2:
search for:
CODE
case 40:
Until you see things like:
CODE
if (NpcDialogue == ID's ||..
Now , in the lower part of the case, add this code in:
CODE
NpcDialogue == $$$$ ||
$$$$'s = The dialogue case (The one you added before)
npcdialogue = 0; = Meaning there won't be any continous dialogue
RemoveAllWindows(); = This removes all windows open (any chats open)
And that's all there is to it! it may be a bit confusing, but you'll get it eventually.
VI. Now, say you wanted to change the max hit of a monster, or make a monster attack using different animation?. Then you can do it by opening up npchandler.java and searching for:
CODE
public boolean AttackPlayer(int NPCID) {
Scroll down a little until you start seeing things like:
CODE
} else if (npcs[NPCID].npcType == 41) {
npcs[NPCID].animNumber = 0x037; //chicken attack
Now then, add this code:
CODE
} else if (npcs[NPCID].npcType == @@@@) {
npcs[NPCID].animNumber = !!!!; //Attack
hitDiff = ^^^^ + misc.random(****);
@@@@'s = The npc id
!!!!'s = The animation of the monster when it attacks
^^^^'s = The guarenteed, minimum of damage the of damage the monster will hit 100%
****'s = The extra damage it will hit.
So about the damage, it works this way. If i had a code like:
CODE
hitDiff = 3 + misc.random(7);
This code would mean, that the monster is guarenteed to hit atleast 3 damage and hit an extra 1-7 damage any time.
That's all there really is to it.
VII. Have you been trying to make a minigame with NPC death teleports but just can't get it? well, you're about to find out why.
Open up npchandler.java and search for:
CODE
public void MonsterDropItem(int NPCID)
And underneath it (scroll down a little) add in a code, using this format:
CODE
if(npcs[NPCID].npcType == %%%%) //Karil
{
int Player = npcs[NPCID].StartKilling;
client ppl = (client) server.playerHandler.players[Player];
ppl.sendMessage("A message here");
ppl.teleportToX = XXXX;
ppl.teleportToY = YYYY;
}
%%%'s = The ID of the NPC
ppl.sendMessage("") = The message that gets sent [optional]
ppl.teleportToX = XXXX; = The X coordinate of where the monster teleports you after it's death
ppl.teleportToX = YYYY; = The Y coordinate of where the monster teleports you after it's death
client ppl = (client) server.playerHandler.players[Player]; = Don't change this. This defines "ppl." so it is needed
Well, that was pretty straight forward, i hope you had no difficulties.
VIII. So, this is the last part of the tutorial. This will show you how to make an NPC drop an item.
Ok, so first off, go to item2.java and underneath:
CODE
public class Item2
{
Add a code like this:
CODE
public static int %%%%[] = {995,995,995};
public static int random%%%%()
{
return %%%%[(int)(Math.random()*%%%%.length)];
}
- Fill in EVERY SINGLE % with the same word (eg. Soldier)
- The change 995's to your Item id's that your NPC's drop, use a comma after every drop
Now, go to npchandler.java and underneath:
CODE
public void MonsterDropItem(int NPCID)
Add in this:
CODE
if(npcs[NPCID].npcType == !!!!) {
ItemHandler.addItem(Item2.random%%%%(), npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller(NPCID), false);
}
!!!!'s = The npc ID that you are adding drops to
%%%%'s = The name you put in item2.java (CAPITALS MATTER!!!!!!!!!!)
1 = The amount of the item it will drop.
Well, that's about it.
IX. Well, that concludes my guide on NPC's, if i missed some things that are vital, please PM me. If you get any errors or have questions, don't be shy to post them!
Credits:
zanox96!:! - writing the guide
Difficulty: Ranging from 1/10 to 3/10
Classes modified: Client.java, npc.cfg, autospawn.cfg, npchandler.java
CODE
This guide was written by Sacred of Silabsoft/runelocus/RSPS tutorial forums AKA 00xo0x of Rune-server forums, it is NOT to be used by any individual without his permission.
Table of content:
I. Intro
II. Spawning NPC's
III. Editing an NPC's health
IV. Making an NPC shout something
V. Adding NPC dialogue
VI. Changing an NPC's max hit, attack animation.
VII. Making an NPC teleport you apon death
VIII. How to give an NPC drops
IX. Credits
I. Hello all. This is my guide to NPC's, i spent ALOT more time writing it then you did viewing it, so please leave a comment
II. You can give an NPC and effect, you make an NPC part of your minigame, but without spawning the NPC itself, you can't do anything!
So basically, open up your autospawn.cfg. There you should see spawning codes, now, to add a new NPC, use this format.
CODE
spawn = ### XXXX YYYY 0 0 0 0 0 1 Description
####'s = The npc ID
XXXX = The x coordinate of the NPC you want to add
YYYY= The y coordinate of the NPC you want to add
0 0 0 0 0 1 = The 0's are the heightlevel and the rangex and y's (recommend to leave blank) and the 1 is the walking type, leave it at one too.
Description = Put anything here, maybe the name of the npc or whatever you want.
Now, if you want to add a heightlevel to the NPC (Make it underground or upstairs) then you would either add this before the walking type:
CODE
- 1 = Minus 1 height
1 = plus 1 height
III. So, is there a monster that is too hard/too easy to defeat? well , you can fix that!
Open up npc.cfg, there you should see:
CODE
//----NpcID-----NpcName-------------------------combat--health
Underneath that, add this code:
CODE
npc = $$$ @@@@ * %
(Don't create any extra space between the digits)
$$$'s = The Id of the monster.
@@@@'s = The name of the monster (doesn't matter )
* = The monsters combat, just leave it at the monsters natural level
% = The monsters health, you can change it to whatever suits you.
IV. Now then, we are going to make an NPC announce something so you don't have to sit there and advertise it yourself (Beware, npc overhead text creates lag! so don't add too much)
Open up npchandler.java, and search for:
CODE
npcs.RandomWalk == true) {
Underneath, you should see NPC overhead text codes. To make a new one, add this code in underneath:
CODE
(npcs.RandomWalk == true) {
CODE
if (npcs.npcType == ^^^^) {
if (misc.random2(30) <= 2) {
npcs.updateRequired = true;
npcs.textUpdateRequired = true;
npcs.textUpdate = "EDIT YOUR TEXT HERE!";
}
}
^^^^'s = The NPC id that is supposed to shout out the text
EDIT YOUR TEXT HERE = The text, self explanatory (note, don't delete the two "")
You can initially change:
CODE
if (misc.random2(30) <= 2)
That's only if you want to change the rate that the npc talks at (faster, slower)
V. Now, here is where it gets slightly more challenging. Creating NPC dialogue. What is npc dialogue?, you may ask. Npc dialogue is basically a chat you have with an NPC.
Open up client.java.
Now, first off, we need to make the chat itself.
Search for:
CODE
public void UpdateNPCChat() {
Underneath it, you should see a few cases. Now, to add our dialogue, we need to use this format:
CODE
case ****:
sendFrame126(GetNpcName(NpcTalkTo), 4902);
sendFrame126("YOUR TEXT HERE", 4903);
sendFrame126("YOUR TEXT HERE", 4904);
sendFrame126("YOUR TEXT HERE", 4905);
sendFrame126("YOUR TEXT HERE", 4906);
sendFrame75(NpcTalkTo, 4901);
sendFrame164(4900);
NpcDialogueSend = true;
break;
Now to explain it.
case **** = The case number, it doesn't matter which case, it could be case 734 or case 666 or case 1000, it doesn't matter! (just make sure the case isn't already in use)
YOUR TEXT HERE = the text that will appear once you talk to the NPC
sendFrame126(GetNpcName(NpcTalkTo), 4902); = The npc's name, leave it as it is
Ok, now that we have that added, we need to make the NPC say the dialogue when we talk to them.
Search for:
CODE
case 155:
This is our first click NPC void (meaning the first option on an NPC). Now , to make the npc use the case of dialogue when we use first click, we need to add in using this format:
CODE
if (NPCID == @@@@) {
skillX = server.npcHandler.npcs[NPCSlot].absX;
skillY = server.npcHandler.npcs[NPCSlot].absY;
NpcWanneTalk = ^^^^;
}
@@@@'s = the ID of the npc that will initiate the case of dialogue
^^^^'s = The dialogue case (The one you added before)
Congratualations! Now you have your dialogue set up.
Now that we have our dialogue, we need to decide on a few things.
1. Do you want to continue the dialogue?
2. Do you want to end the dialogue?
Option 1:
Make a new case of dialogue using the same format as above. But this time, make the case 1 number higher then the one it will continue on to. So for example, if your dialogue case was 77, we'd make the new case 78, and if it was 90, we'd make it 91 ect.
Once you have your dialogue search for:
CODE
case 40:
Until you see things like:
CODE
if (NpcDialogue == ID's ||..
Now, add the case of your dialogue you want to continue (in the upper half of the case), using this format:
CODE
NpcDialogue == $$$$ ||
$$$$'s = The dialogue case (The one you added before)
NpcDialogue += 1; = This means that the case of dialogue will go up one more (This is why you wanted to add the case 1 more). So for example, we add the case 666,this would make it, so when we click "continue" it would go to case 667.
And there you go! you can make your dialogue continue as many times as you want , so go ahead!
Option 2:
search for:
CODE
case 40:
Until you see things like:
CODE
if (NpcDialogue == ID's ||..
Now , in the lower part of the case, add this code in:
CODE
NpcDialogue == $$$$ ||
$$$$'s = The dialogue case (The one you added before)
npcdialogue = 0; = Meaning there won't be any continous dialogue
RemoveAllWindows(); = This removes all windows open (any chats open)
And that's all there is to it! it may be a bit confusing, but you'll get it eventually.
VI. Now, say you wanted to change the max hit of a monster, or make a monster attack using different animation?. Then you can do it by opening up npchandler.java and searching for:
CODE
public boolean AttackPlayer(int NPCID) {
Scroll down a little until you start seeing things like:
CODE
} else if (npcs[NPCID].npcType == 41) {
npcs[NPCID].animNumber = 0x037; //chicken attack
Now then, add this code:
CODE
} else if (npcs[NPCID].npcType == @@@@) {
npcs[NPCID].animNumber = !!!!; //Attack
hitDiff = ^^^^ + misc.random(****);
@@@@'s = The npc id
!!!!'s = The animation of the monster when it attacks
^^^^'s = The guarenteed, minimum of damage the of damage the monster will hit 100%
****'s = The extra damage it will hit.
So about the damage, it works this way. If i had a code like:
CODE
hitDiff = 3 + misc.random(7);
This code would mean, that the monster is guarenteed to hit atleast 3 damage and hit an extra 1-7 damage any time.
That's all there really is to it.
VII. Have you been trying to make a minigame with NPC death teleports but just can't get it? well, you're about to find out why.
Open up npchandler.java and search for:
CODE
public void MonsterDropItem(int NPCID)
And underneath it (scroll down a little) add in a code, using this format:
CODE
if(npcs[NPCID].npcType == %%%%) //Karil
{
int Player = npcs[NPCID].StartKilling;
client ppl = (client) server.playerHandler.players[Player];
ppl.sendMessage("A message here");
ppl.teleportToX = XXXX;
ppl.teleportToY = YYYY;
}
%%%'s = The ID of the NPC
ppl.sendMessage("") = The message that gets sent [optional]
ppl.teleportToX = XXXX; = The X coordinate of where the monster teleports you after it's death
ppl.teleportToX = YYYY; = The Y coordinate of where the monster teleports you after it's death
client ppl = (client) server.playerHandler.players[Player]; = Don't change this. This defines "ppl." so it is needed
Well, that was pretty straight forward, i hope you had no difficulties.
VIII. So, this is the last part of the tutorial. This will show you how to make an NPC drop an item.
Ok, so first off, go to item2.java and underneath:
CODE
public class Item2
{
Add a code like this:
CODE
public static int %%%%[] = {995,995,995};
public static int random%%%%()
{
return %%%%[(int)(Math.random()*%%%%.length)];
}
- Fill in EVERY SINGLE % with the same word (eg. Soldier)
- The change 995's to your Item id's that your NPC's drop, use a comma after every drop
Now, go to npchandler.java and underneath:
CODE
public void MonsterDropItem(int NPCID)
Add in this:
CODE
if(npcs[NPCID].npcType == !!!!) {
ItemHandler.addItem(Item2.random%%%%(), npcs[NPCID].absX, npcs[NPCID].absY, 1, GetNpcKiller(NPCID), false);
}
!!!!'s = The npc ID that you are adding drops to
%%%%'s = The name you put in item2.java (CAPITALS MATTER!!!!!!!!!!)
1 = The amount of the item it will drop.
Well, that's about it.
IX. Well, that concludes my guide on NPC's, if i missed some things that are vital, please PM me. If you get any errors or have questions, don't be shy to post them!
Credits:
zanox96!:! - writing the guide

