Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] OdinMS NPC editing commans

Status
Not open for further replies.
Elite Diviner
Joined
Apr 6, 2008
Messages
447
Reaction score
0
Default Simple OdinMS NPC Editing Commands

As the title says, this is the basics of NPC coding with what Odin currently provides.
If you're not sure how to use these you'll need to fiddle about with the NPCs until you know how to get an NPC up and running. What I've included here shows examples of how each are used, but doesn't state where they should be placed; if you know what you're doing you will know where they should all go.
__________________________________________________ ______________________

Comments

/* This is a multi-line comment. This will not affect the NPC in any way, shape or form.
However it is very useful: If you were to add a comment to the top of every NPC.js file saying who the NPC is and in what Town they appear, you wouldn't get confused by having multiple NPC.js files open at the same time.
*/

// This is also a comment, but used on a single line. This can be very useful as well. For instance, if you had a lot of IDs in the same NPC.js file, you could put a single-line comment after the end of the line to say what the IDs relate to.

Examples:

Code:
/* Lakelis
Kerning City - KPQ NPC
*/

cm.warp(60000, 0); // Warps to Southperry.
__________________________________________________ ______________________

cm.[Commands]

dispose
Ends the conversation with an NPC.
How to use: cm.dispose();

sendNext
Shows a conversation window with a 'Next' button.
How to use: cm.sendNext("[text]");

sendPrev
Shows a conversation window with a 'Prev' (previous) button.
How to use: cm.sendPrev("[text]");

sendNextPrev
Shows a conversation window with a 'Next' and 'Prev' button (see above).
How to use: cm.sendNextPrev("[text]");

sendOk
Shows a conversation window with an 'Ok' button.
How to use: cm.sendOk("[text]");

sendYesNo
Shows a conversation window with a 'Yes' and 'No' button, 'No' ends the conversation unless otherwise stated.
How to use: cm.sendYesNo("[text]");

sendAcceptDecline
Shows a conversation window with an 'Accept' and 'Decline' button. 'Decline' ends the conversation unless otherwise stated.
How to use: cm.sendAcceptDecline("[text]");

sendSimple
Shows a conversation window with no buttons.
How to use: cm.sendAcceptSimple("[text]");

sendStyle
Shows a style-select window.
How to use: cm.sendStyle("[Text]", [variable]); // You'll need to delcare the variable in a Var statement.

warp
Warps the player to a map.
How to use: cm.warp([mapid], [portal]); // Set [portal] as 0 if you want default.

openShop
Opens a shop window.
How to use: cm.openShop([shopid]);

haveItem
Checks if the player has an item (in their inventories or equipped).
How to use: cm.haveItem([itemid]);

gainItem
Gives the player an item/takes an item from a player.
How to use: cm.gainItem([itemid],[ammount]); // Change [ammount] to -[ammount] to take an item.

changeJob
Changes the job of the player.
How to use: cm.changeJob([jobid]);

getJob
Finds out what job the player has.
How to use: cm.getJob();

startQuest
Starts a quest.
How to use: cm.startQuest([questid]);

completeQuest
Finishes a quest.
How to use: cm.completeQuest([questid]);

forfeitQuest
Forfeits a quest.
How to use: cm.forfeitQuest([questid]);

getMeso
Finds out how many mesos a player has.
How to use: cm.getMeso();

gainMeso
Gives a player mesos/takes mesos from a player.
How to use: cm.gainMeso([ammount]); // use -[ammount] to take mesos.

gainExp
Gives a player exp/takes exp from a player.
How to use: cm.gainExp([ammount]); // use -[ammount] to take exp.

getLevel
Finds out the level of the player.
How to use: cm.getLevel();

teachSkill
Teaches a player a skill.
How to use: cm.teachSkill([skillid],[skilllevel],[maxskilllevel]);

isGM
Finds out if the player is a GM or not.
How to use: cm.isGM();

get[Stat]
Finds out the [Stat] of the player. [Stat] being: HP, MP, STR, DEX, INT, LUK.
How to use: cm.get[Stat]();

--

Some of the above can be used in IF statements. Here is an example of the Thief 1st Job Advancement:


Code:
if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
		if (cm.[B]getLevel[/B]() >= 10 && cm.[B]getChar[/B]().[B]getDex[/B]() >= 25) {
			cm.[B]sendNext[/B]("So you decided to become a #rThief#k?");
		} else {
			cm.[B]sendOk[/B]("Train a bit more and I can show you the way of the #rThief#k.")
			cm.[B]dispose[/B]();
		}
} else if (status == 1) {
	cm.send[B]NextPrev[/B]("It is an important and final choice. You will not be able to turn back.");
	} else if (status == 2) {
		cm.[B]sendYesNo[/B]("Do you want to become a #rThief#k?");
	} else if (status == 3) {
		if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
			cm.[B]changeJob[/B](net.sf.odinms.client.MapleJob.THIEF);
			cm.[B]sendOk[/B]("So be it! Now go, and go with pride.");
			cm.[B]dispose[/B]();
		}
	} 
}

Breaking this section of code apart line by line will show you some examples of how some of these NPC-related commands can be used:

if (cm.getJob().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
if (cm.getLevel() >= 10 && cm.getChar().getDex() >= 25) {
cm.sendNext("So you decided to become a #rThief#k?");
} else {
cm.sendOk("Train a bit more and I can show you the way of the #rThief#k.")
cm.dispose();
}
} else if (status == 1) {
cm.sendNextPrev("It is an important and final choice. You will not be able to turn back.");
} else if (status == 2) {
cm.sendYesNo("Do you want to become a #rThief#k?");
} else if (status == 3) {
if (cm.getJob().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
cm.changeJob(net.sf.odinms.client.MapleJob.THIEF);
cm.sendOk("So be it! Now go, and go with pride.");
cm.dispose();
}
}
}
__________________________________________________ ______________________

MapleJob.[Job]

These can be used with the MapleJob. statements:
BEGINNER
WARRIOR
FIGHTER
CRUSADER
HERO
PAGE
WHITEKNIGHT
PALADIN
SPEARMAN
DRAGONKNIGHT
DARKKNIGHT
MAGICIAN
FP_WIZARD
FP_MAGE
FP_ARCHMAGE
IL_WIZARD
IL_MAGE
IL_ARCHMAGE
CLERIC
PRIEST
BISHOP
BOWMAN
HUNTER
RANGER
BOWMASTER
CROSSBOWMAN
SNIPER
CROSSBOWMASTER
THIEF
ASSASSIN
HERMIT
NIGHTLORD
BANDIT
CHIEFBANDIT
SHADOWER
GM
SUPERGM


Example:


if (cm.getJob().equals(net.sf.odinms.client.MapleJob.SUPERGM)) {
cm.sendNext("Hi, GM!");
}

These can be used to easily code a Job Advancing NPC.
__________________________________________________ ______________________

NPC Text Commands

#b = Blue text.
#c[itemid]# Shows how many [itemid] the player has in their inventory.
#d = Purple text.
#e = Bold text.
#f[imagelocation]# - Shows an image inside the .wz files.
#g = Green text.
#h # - Shows the name of the player.
#i[itemid]# - Shows a picture of the item.
#k = Black text.
#l - Selection close.
#m[mapid]# - Shows the name of the map.
#n = Normal text (removes bold).
#o[mobid]# - Shows the name of the mob.
#p[npcid]# - Shows the name of the NPC.
#q[skillid]# - Shows the name of the skill.
#r = Red text.
#s[skillid]# - Shows the image of the skill.
#t[itemid]# - Shows the name of the item.
#v[itemid]# - Shows a picture of the item.
#x - Returns "0%" (need more information on this).
#z[itemid]# - Shows the name of the item.
#B[%]# - Shows a 'progress' bar.
#F[imagelocation]# - Shows an image inside the .wz files.
#L[number]# Selection open.
\r\n - Moves down a line.

(If you know of any others, please tell me).

Example on using #f and #F (credits to Rozene for the code + pic):

Code:
#fUI/UIWindow.img/QuestIcon/3/0# = Select Item #fUI/UIWindow.img/QuestIcon/4/0# = Reward!! #fUI/UIWindow.img/QuestIcon/5/0# = Question Mark Box #fUI/UIWindow.img/QuestIcon/6/0# = Fame #fUI/UIWindow.img/QuestIcon/7/0# = Meso #fUI/UIWindow.img/QuestIcon/8/0# = EXP. #fUI/UIWindow.img/QuestIcon/9/0# = Pet Closeness
Would give:
woainioh - [Release] OdinMS NPC editing commans - RaGEZONE Forums

__________________________________________________ ______________________

Selections[Job]

Selections can be used in NPC conversations. For example, when Dark Lord asks you if you want to become an Assassin or a Bandit, that window includes selections.

Selections can be made using #L followed by the selection number (starting at 0), followed by another #, then [selection text], then #l to end the selection. They are most commonly used with cm.sendSimple windows.

Example:
Code:
cm.sendSimple("Which would you like to become? #L0#Assassin#l #L1#Bandit#l");
This would give:

Which would you like to become? Assassin Bandit

However, this would look quite unprofessional as both the selections would be on the same line.

To fix this you can use \r\n (new row) and add some text formatting to your script (see above for NPC Text Formatting). With these, you could make:

Code:
cm.sendSimple("Which would you like to become? #b\r\n#L0#Assassin#l\r\n#L1#Bandit#l#k");
Which would give:

Which would you like to become?
 
Initiate Mage
Joined
Feb 5, 2008
Messages
4
Reaction score
0
how would we use the selection thingy....
could you make that part a bit more detailed:
Code:
if (selection == 0) {
cm.sendNext("Are you sure you want to become an Assassin?");
} else if (selection == 1) {
cm.sendNext("Are you sure you want to become a Bandit?");
}

like after they click Next would that be like...

Code:
if (status == 98) {
cm.changeJob(net.sf.odinms.client.MapleJob.ASSASSIN);
cm.sendOk("Now go show the world the power of #rAssassins#b!");
} else if (status == 100) {
cm.changeJob(net.sf.odinms.client.MapleJob.BANDIT);
cm.sendNext("Now go show the world the power of #rBandits#b!");
}

And also... would the job for Grendel the really old be:

Code:
/*
NPC: Grendel the Really Old
Only first and second job advancement!
*/
importPackage(net.sf.odinms.client);

var status = 0;
var job;


function start() 
{
    status = -1;
    action(1, 0, 0);
}



function action(mode, type, selection) 
{
    if (mode == -1) 
    {
        cm.dispose();
    } 
    else 
    {
    

//First job
if (cm.getJob().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
		if (cm.getLevel() >= 8 || 9 || 10 || 11 || 12 || 13 && cm.getChar().getINT() >= 20) {
			cm.sendNext("So you want to be a #rMagician#k?");
		} else {
			cm.sendOk("I am sorry but it seems as if you are not ready to become a #rMagician#k. Please come back when you have the minimum requirements.")
			cm.dispose();
		}
} else if (status == 1) {
	cm.sendNextPrev("Please make sure that becoming a #rMagician#k is what you want, because after you become on there is no turning back.");
	} else if (status == 2) {
		cm.sendYesNo("Do you really want to become a #rMagician#k?");
	} else if (status == 3) {
		if (cm.getJob().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
			cm.changeJob(net.sf.odinms.client.MapleJob.MAGICIAN);
			cm.gainMeso([10000]);			
			cm.sendOk("Since you became a magician, you get a complimentary #r10,000 mesos#b to help you out. Now go show the world the magical power of mages!");
			cm.dispose();
		}
	} 
}
	
//thats the end of first job
//now its time for second job
else if (cm.getJob().equals(net.sf.odinms.client.MapleJob.MAGICIAN)) {

if (cm.getLevel() >= 30) {
status = 5;
cm.sendNext("Hey it's you again! You are now strong enough to job advance!");
} else {
status = 4;
cm.sendOk("I am sorry but it seems as if you are not the required level to job advance. Please make sure you are then come back to see me.")
cm.dispose();
		}
}

else if (status == 6)
{
cm.sendSimple("Which would you like to become? #b\r\n#L0#Cleric#l\r\n#L1#Ice Lightning#l\r\n#L2#Fire Poison#l#k");
}

else if (selection == 0) {
status = 7;
cm.sendNext("Are you sure you want to become an #rCleric#b?");
} 
else if (selection == 1) {
status = 9;
cm.sendNext("Are you sure you want to become a #rIce Lightning#b?");
}

else if (selection == 2)
{
status = 11;
cm.sendNext("Are you sure you want to become a #rFire Poison#b?");
}

else if (status == 8)
{
		cm.changeJob(net.sf.odinms.client.MapleJob.CLERIC);
		cm.gainMeso([10000]);			
		cm.sendOk("Congratulations on becoming a #rCleric#b. You get a complimentary #r10,000 mesos#b to help you out. Now go show the world the healing powers of the #rCleric#b!");
		cm.dispose();
}

else if (status == 10)
{
		cm.changeJob(net.sf.odinms.client.MapleJob.FP_WIZARD);
		cm.gainMeso([10000]);			
		cm.sendOk("Congratulations on becoming a #rIce Lightning#b. You get a complimentary #r10,000 mesos#b to help you out. Now go show the world the freezing powers of the #rIce Lightning#b!");
		cm.dispose();
}

else if (status == 12)
{
		cm.changeJob(net.sf.odinms.client.MapleJob.IL_WIZARD);
		cm.gainMeso([10000]);			
		cm.sendOk("Congratulations on becoming a #rFire Poison#b. You get a complimentary #r10,000 mesos#b to help you out. Now go show the world the burning powers of the #rFire Poison#b!");
		cm.dispose();
}

//thats the end of the second job

	}
???? because i just made taht based off of your tutorial XD

and also... when you make the npc... do you have to recompile anything??

and also this thread should be stickied =D
 
Last edited:
Initiate Mage
Joined
Apr 19, 2008
Messages
4
Reaction score
0
thx its helpfull^^ Do you add the Reactor thing too?

and do you know how i make a time thing ?? so if player get warped map time going on with ...maps?
 
The almighty chicken
Loyal Member
Joined
Apr 7, 2008
Messages
570
Reaction score
31
Very #e very#n nice =]
 
Last edited:
The almighty chicken
Loyal Member
Joined
Apr 7, 2008
Messages
570
Reaction score
31
only this is a little.. weird:
Code:
NPC Text Commands

#b = Blue text.
#c[itemid]# Shows how many [itemid] the player has in their inventory.
#d = Purple text.
#e = Bold text.
#f[imagelocation]# - Shows an image inside the .wz files.
#g = Green text.
#h # - Shows the name of the player.
#i[itemid]# - Shows a picture of the item.
#k = Black text.
#l - Selection close.
#m[mapid]# - Shows the name of the map.
#n = Normal text (removes bold).
#o[mobid]# - Shows the name of the mob.
#p[npcid]# - Shows the name of the NPC.
#q[skillid]# - Shows the name of the skill.
#r = Red text.
#s[skillid]# - Shows the image of the skill.
#t[itemid]# - Shows the name of the item.
#v[itemid]# - Shows a picture of the item.
#x - Returns "0%" (need more information on this).
#z[itemid]# - Shows the name of the item.
#B[%]# - Shows a 'progress' bar.
#F[imagelocation]# - Shows an image inside the .wz files.
#L[number]# Selection open.
\r\n - Moves down a line.

#B progress bar?! never seen that before

btw, all things should end with a # right?
so it's like
cm.sendOK("#eHello!#");
 
Junior Spellweaver
Joined
Apr 29, 2008
Messages
184
Reaction score
0
only this is a little.. weird:
Code:
NPC Text Commands

#b = Blue text.
#c[itemid]# Shows how many [itemid] the player has in their inventory.
#d = Purple text.
#e = Bold text.
#f[imagelocation]# - Shows an image inside the .wz files.
#g = Green text.
#h # - Shows the name of the player.
#i[itemid]# - Shows a picture of the item.
#k = Black text.
#l - Selection close.
#m[mapid]# - Shows the name of the map.
#n = Normal text (removes bold).
#o[mobid]# - Shows the name of the mob.
#p[npcid]# - Shows the name of the NPC.
#q[skillid]# - Shows the name of the skill.
#r = Red text.
#s[skillid]# - Shows the image of the skill.
#t[itemid]# - Shows the name of the item.
#v[itemid]# - Shows a picture of the item.
#x - Returns "0%" (need more information on this).
#z[itemid]# - Shows the name of the item.
#B[%]# - Shows a 'progress' bar.
#F[imagelocation]# - Shows an image inside the .wz files.
#L[number]# Selection open.
\r\n - Moves down a line.

#B progress bar?! never seen that before

btw, all things should end with a # right?
so it's like
cm.sendOK("#eHello!#");

Well not ALL, but you could end "#e" whenever you want. E.G., #eHello! welcome to BlahBlah MS!# Blah blah blah *Black Text here cause i ended #e*
 
The almighty chicken
Loyal Member
Joined
Apr 7, 2008
Messages
570
Reaction score
31
and what do you get when u use like #e#gHello, is this bolded & green text?!#

can u use that to create any color you want? ^^
like green+red = brown? xD
 
Newbie Spellweaver
Joined
Apr 18, 2008
Messages
84
Reaction score
1
O_O!! OMG HORAYY!!!! THANK YOU THANK YOU THANK YOU THANK YOU !!!!!!!!!
beeen looking everywhere for this xD
 
Newbie Spellweaver
Joined
May 29, 2008
Messages
39
Reaction score
0
nid a bit help
Code:
*/
var status = 0;
var beauty = 0;
var haircolor = Array();
var skin = Array(0, 1, 2, 3, 4);
var hair = Array(30000, 30020, 30030, 30040, 30050, 30060, 30110, 30120, 30130, 30140, 30150, 30160, 30170, 30180, 30190, 30200, 30210, 30220, 30230, 30240, 30250, 30260, 30270, 30280, 30290, 30300, 30310, 30320, 30330, 30340, 30350, 30360, 30370, 30400, 30410, 30420, 30430, 30440, 30450, 30460, 30470, 30480, 30490, 30510, 30520, 30530, 30540, 30550, 30560, 30570, 30580, 30590, 30600, 30610, 30620, 30630, 30640, 30650, 30660, 30700, 30710, 30720, 30780, 307090, 30800, 30810, 30730, 30760);
var hairnew = Array();
var face = Array(20000, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20009, 20010, 20011, 20012, 20013, 20014, 20016, 20017, 20018, 20019, 20020, 20021, 20022, 20023, 20024);
var facenew = Array();
var colors = Array();

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			if(cm.getChar().isGM()
 == false) {
				cm.sendOk("You aren't a GM!");
				cm.dispose();
			} else {
				if(cm.getChar().getGender() == 0) {
					cm.sendSimple("Hey there! I could change the way you look! What would you like to change?\r\n#L0#Skin#l\r\n#L1#Hair#l\r\n#L2#Hair Color#l\r\n#L3#Eye#l\r\n#L4#Eye Color#l");
				}else {
					cm.sendOk("Currently I am only serving males, but you should try NimaKIN!");
					cm.dispose();
				}
			}
		} else if (status == 1) {
			if (selection == 0) {
				beauty = 1;
				cm.sendStyle("Pick one?", skin);
			} else if (selection == 1) {
				beauty = 2;
				hairnew = Array();
				for(var i = 0; i < hair.length; i++) {
					hairnew.push(hair[i] + parseInt(cm.getChar().getHair()
 % 10));
				}
				cm.sendStyle("Pick one?", hairnew);
			} else if (selection == 2) {
				beauty = 3;
				haircolor = Array();
				var current = parseInt(cm.getChar().getHair()
/10)*10;
				for(var i = 0; i < 8; i++) {
					haircolor.push(current + i);
				}
				cm.sendStyle("Pick one?", haircolor);
			} else if (selection == 3) {
				beauty = 4;
				facenew = Array();
				for(var i = 0; i < face.length; i++) {
					facenew.push(face[i] + cm.getChar().getFace()
 % 1000 - (cm.getChar().getFace()
 % 100));
				}
				cm.sendStyle("Pick one?", facenew);
			} else if (selection == 4) {
				beauty = 5;
				var current = cm.getChar().getFace()
 % 100 + 20000;
				colors = Array();
				colors = Array(current , current + 100, current + 200, current + 300, current +400, current + 500, current + 600, current + 700);
				cm.sendStyle("Pick one?", colors);
			}
		}
		else if (status == 2){
			cm.dispose();
			if (beauty == 1){
				cm.setSkin(skin[selection]);
			}
			if (beauty == 2){
				cm.setHair(hairnew[selection]);
			}
			if (beauty == 3){
				cm.setHair(haircolor[selection]);
			}
			if (beauty == 4){
				cm.setFace(facenew[selection]);
			}
			if (beauty == 5){
				cm.setFace(colors[selection]);
			}
		}
	}
}

which part should i delete/change to make the npc public to all?
 
Initiate Mage
Joined
Dec 13, 2003
Messages
0
Reaction score
0
What is the correct "way" of disposing ?

I tried adding a cm.dispose() after all my commands but still require a re-login.
 
Junior Spellweaver
Joined
Jan 14, 2008
Messages
113
Reaction score
0
thank you, this will help many of us, if they can find it -.- it took me like a half an hour
 
Newbie Spellweaver
Joined
Jun 20, 2008
Messages
43
Reaction score
0
I noticed that there isn't a command for giving levels. So I guess an alternative would be to give them the amount of experience to get them to that level?
 
Newbie Spellweaver
Joined
Apr 5, 2008
Messages
18
Reaction score
0
I need help also. I am trying to script sera the first npc. For you to be able to pic your job and she will make you the correct level and send you to your job advancement place. This is what i got so far. Just did the first one to test and it isnt working./




var wui = 0;

function start() {
cm.sendSimple("Which would you like to become? #b\r\n#L0#Magician#l\r\n#L1#Other Job#l#k");
}

function action(mode, type, selection) {
if (selection == 0)}
}
if (selection == 0) {
cm.sendYesNo("Are you sure you want to be a Magician?");
cm.gainExp(1625);
cm.gainItem(1002562, 1);
cm.gainItem(01052081, 1);
cm.warp(100000000, 0);
} else if (selection == 1) {
cm.sendYesNo("Are you sure you want to be Other Job?");
}
 
Status
Not open for further replies.
Back
Top