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!

[Help] learning js

Initiate Mage
Joined
Aug 10, 2011
Messages
4
Reaction score
1
Well I've followed this thread http://forum.ragezone.com/f428/add-learning-npcs-start-finish-643364/
and I got stuck on those lines
Code:
var status; 

function start() { // starts the NPC 
    status = -1; // sets the status of the NPC to -1 
    action(1, 0, 0); // sets the mode to 1, type to 0, and selection to 0 for the NPC 
} // closes off the start function
I couldn't figure it out what does the status -1 / 0 / 1 does
I mean , can someone describe me what it does and what is the difference between setting the status as 1 / 0 / -1 ?

Thanks ! , and if you can link me to more "Tutorials" about JS / Java for maplestory I will be glad !
I want to start to code asap , I have enought time for learning and enought skills to learn it :)
 
Newbie Spellweaver
Joined
Dec 30, 2008
Messages
55
Reaction score
15
It calls the function action with the given arguments.
So that means you're calling action right when you click on the npc, and that means also:


Code:
var status;

function start() { // starts the NPC
    status = -1; // sets the status of the NPC to -1
    action(1, 0, 0); // sets the mode to 1, type to 0, and selection to 0 for the NPC
} // closes off the start function

function action(mode, type, selection) { 
// code
// at this point, mode = 1, type = 1, selection = 1.
}
 
Upvote 0
Junior Spellweaver
Joined
Sep 11, 2014
Messages
181
Reaction score
76
At the point type and selection are 0, not 1.

Status just tells you what stage the NPC is at. It doesn't have to be named status though. So if status is 2, it might display text displayed at stage 2 or 3 of the NPC depending on where you started status.
 
Upvote 0
Initiate Mage
Joined
Aug 10, 2011
Messages
4
Reaction score
1
It calls the function action with the given arguments.
So that means you're calling action right when you click on the npc, and that means also:


Code:
var status;

function start() { // starts the NPC
    status = -1; // sets the status of the NPC to -1
    action(1, 0, 0); // sets the mode to 1, type to 0, and selection to 0 for the NPC
} // closes off the start function

function action(mode, type, selection) { 
// code
// at this point, mode = 1, type = 1, selection = 1.
}
I didn't really understood ur explanation but thanks tho
At the point type and selection are 0, not 1.

Status just tells you what stage the NPC is at. It doesn't have to be named status though. So if status is 2, it might display text displayed at stage 2 or 3 of the NPC depending on where you started status.
I think that I've understood , can you explain me this part

var status = 0;

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

function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 1)
status++;
else
status--;
 
Upvote 0
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
Npc scripts act like a state machine. They progress within each state input from the user. This is something stupid that OdinMS's developers implemented back in the day, and can be removed, but that's for another thread. Like ALotOfPosts mentioned, the status variable is the state of the user. It starts at 0, the initial state. Then, when the scripts runs each time, it checks for each state. If the state is 0 (the initial state), it will do x, if it's 1 it will do y and else it will do z.

About your last question, action mode is called when an action is made. In MapleStory an action is either a Yes / No selection in a dialog, a selective dialog, or other buttons that are involved. When a user selects an input of any kind (Yes / No, Accept / Decline) it calls the 'action' function to set the selection. For example, if you sent a Yes / No dialog to the user, and they pressed the No button, the mode will be -1. In the script, it will call 'action(-1, 2, 0)'. Then, as you can see, 'action' checks if the mode is -1. If it is, it disposes the chat and stops it, because the user pressed no. However, if the user would press Yes, the mode would be 1 and it would proceed. The mode 1 is also when the user proceeds in a dialog. So, if the mode is 1, it increases the status and promots to the next dialog.
 
Upvote 0
Custom Title Activated
Loyal Member
Joined
Jan 18, 2010
Messages
3,109
Reaction score
1,139
Npc scripts act like a state machine. They progress within each state input from the user. This is something stupid that OdinMS's developers implemented back in the day, and can be removed, but that's for another thread. Like ALotOfPosts mentioned, the status variable is the state of the user. It starts at 0, the initial state. Then, when the scripts runs each time, it checks for each state. If the state is 0 (the initial state), it will do x, if it's 1 it will do y and else it will do z.

About your last question, action mode is called when an action is made. In MapleStory an action is either a Yes / No selection in a dialog, a selective dialog, or other buttons that are involved. When a user selects an input of any kind (Yes / No, Accept / Decline) it calls the 'action' function to set the selection. For example, if you sent a Yes / No dialog to the user, and they pressed the No button, the mode will be -1. In the script, it will call 'action(-1, 2, 0)'. Then, as you can see, 'action' checks if the mode is -1. If it is, it disposes the chat and stops it, because the user pressed no. However, if the user would press Yes, the mode would be 1 and it would proceed. The mode 1 is also when the user proceeds in a dialog. So, if the mode is 1, it increases the status and promots to the next dialog.

I've been working on NPC's for years and since you brought it up I thought I'd ask. According to OdinMS's structure, you have 'mode, type, selection'. However, I have never in my time of using an NPC scripts used the 'type' variable for anything. Most people say that there's no use of it, and I was wondering if you could explain to me what exactly 'type' does and why you set type to two when calling a(n) negative action of no/decline?

I didn't really understood ur explanation but thanks tho

I think that I've understood , can you explain me this part

Simple!

PHP:
function action(mode, type, selection) {
if (mode == -1) { // Like Fraysa said, when you click 'No' or 'Decline', this happens. The Npc will dispose.
cm.dispose();
} else {
if (mode == 1) // Here, if they click Yes, Accept, or even click a Selection, it will increment the status. This could mean if you click Yes, it says "Thanks!" or whatever after clicking yes.
status++;
else // Otherwise, you have modes like -2 and such, in which this case you just go back. Examples would be when you have Next and Previous, Previous will go down a status so you can re-read the previous window.
status--;
 
Upvote 0
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
I've been working on NPC's for years and since you brought it up I thought I'd ask. According to OdinMS's structure, you have 'mode, type, selection'. However, I have never in my time of using an NPC scripts used the 'type' variable for anything. Most people say that there's no use of it, and I was wondering if you could explain to me what exactly 'type' does and why you set type to two when calling a(n) negative action of no/decline?



Simple!

PHP:
function action(mode, type, selection) {
if (mode == -1) { // Like Fraysa said, when you click 'No' or 'Decline', this happens. The Npc will dispose.
cm.dispose();
} else {
if (mode == 1) // Here, if they click Yes, Accept, or even click a Selection, it will increment the status. This could mean if you click Yes, it says "Thanks!" or whatever after clicking yes.
status++;
else // Otherwise, you have modes like -2 and such, in which this case you just go back. Examples would be when you have Next and Previous, Previous will go down a status so you can re-read the previous window.
status--;

Type, I believe, is just the last sent type -- I'm not sure how OdinMS rephrases it, but here's a quick explanation: Each dialog has a type so the client knows how to handle it (if you notice at the beginning of the Npc text dialog packet, it includes a byte for the type). For example - a Yes / No dialog's type is 2. So, when you send a Yes / No dialog, and then sends the input from the user, it also contains the last type that you sent. That way you can compare (a mini hack-check) for the last sent type to see if it's matching so players don't send wrong values. It also sends it on the script. Pretty useless for the script, though.
 
Upvote 0
Custom Title Activated
Loyal Member
Joined
Jan 18, 2010
Messages
3,109
Reaction score
1,139
Type, I believe, is just the last sent type -- I'm not sure how OdinMS rephrases it, but here's a quick explanation: Each dialog has a type so the client knows how to handle it (if you notice at the beginning of the Npc text dialog packet, it includes a byte for the type). For example - a Yes / No dialog's type is 2. So, when you send a Yes / No dialog, and then sends the input from the user, it also contains the last type that you sent. That way you can compare (a mini hack-check) for the last sent type to see if it's matching so players don't send wrong values. It also sends it on the script. Pretty useless for the script, though.

Ohh! Yeah I know what you mean, when I was messing with the npc chat packets a while back I saw that it sends 'lastMsg' which was the last type (byte). Like I thought, not really any use for it. Well, thanks for the insight :p
 
Upvote 0
Initiate Mage
Joined
Aug 10, 2011
Messages
4
Reaction score
1
Npc scripts act like a state machine. They progress within each state input from the user. This is something stupid that OdinMS's developers implemented back in the day, and can be removed, but that's for another thread. Like ALotOfPosts mentioned, the status variable is the state of the user. It starts at 0, the initial state. Then, when the scripts runs each time, it checks for each state. If the state is 0 (the initial state), it will do x, if it's 1 it will do y and else it will do z.

About your last question, action mode is called when an action is made. In MapleStory an action is either a Yes / No selection in a dialog, a selective dialog, or other buttons that are involved. When a user selects an input of any kind (Yes / No, Accept / Decline) it calls the 'action' function to set the selection. For example, if you sent a Yes / No dialog to the user, and they pressed the No button, the mode will be -1. In the script, it will call 'action(-1, 2, 0)'. Then, as you can see, 'action' checks if the mode is -1. If it is, it disposes the chat and stops it, because the user pressed no. However, if the user would press Yes, the mode would be 1 and it would proceed. The mode 1 is also when the user proceeds in a dialog. So, if the mode is 1, it increases the status and promots to the next dialog.

Thanks alot for your time , I really appreciate your explanation and the fact that you've helped me , you've helped me
alot ! !
 
Upvote 0
Back
Top