- Joined
- Apr 27, 2008
- Messages
- 18
- Reaction score
- 0
This was posted on Odinms forum when it was alive!
I thought this could help some people make their own NPCs or
help solve some problems with their NPCs
I give all credits to TrystD of OdinMS Forum
-------------------------------------------------------------------------
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:
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:
__________________________________________________ ______________________
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:
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:
__________________________________________________ ______________________
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:
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:
--
To then put the selections in to action, you'd need to start a new status, adding the following IF statement within:
Code:
Now go on and make your own custom NPC!
Credit: TrystD
I thought this could help some people make their own NPCs or
help solve some problems with their NPCs
I give all credits to TrystD of OdinMS Forum
-------------------------------------------------------------------------
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:
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:
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
__________________________________________________ ______________________
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");
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");
--
To then put the selections in to action, you'd need to start a new status, adding the following IF statement within:
Code:
Et cetera...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?");
}
Now go on and make your own custom NPC!
Credit: TrystD