SSSHSTORY
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Vote for SSSHSTORY
MapleStoryMapleStory
Hay Day Hack Tool V 1.8.rar Mediafire

Sun Jun 15, 2014 2:29 pm by mykmark

Hay Day Hack Tool V 1.8.rar Mediafire
http://tinyurl.com/okfrpnc

Comments: 0

Manga Studio 5 Download

Sun Jun 15, 2014 1:48 pm by mykmark

Manga Studio 5 Download
http://tinyurl.com/ksoqhm9

Comments: 0

The Commodores - The Ultimate Collection (1997)

Sun Jun 15, 2014 4:36 am by mykmark

The Commodores - The Ultimate Collection (1997)
http://tinyurl.com/lg2vwxc

Comments: 0

Vanquish Xbox 360 Pdf Manual

Sat Jun 14, 2014 3:23 pm by mykmark

Vanquish Xbox 360 Pdf Manual > http://tinyurl.com/njkek8a


Comments: 1

Vanquish Xbox 360 Pdf Manual

Sat Jun 14, 2014 3:23 pm by mykmark

Vanquish Xbox 360 Pdf Manual > http://tinyurl.com/njkek8a


Comments: 0

Stargate Universe Saison 3 Hacker Streaming

Sat Jun 14, 2014 2:28 pm by mykmark

Stargate Universe Saison 3 Hacker Streaming > http://tinyurl.com/krv3xfz


Comments: 0

Man Sex Animal 3gp Video

Sat Jun 14, 2014 9:13 am by mykmark

Man Sex Animal 3gp Video
http://tinyurl.com/lyaagbd

Comments: 1

Www Girls Horse Xxx Video Com

Fri Jun 06, 2014 1:40 pm by mykmark

Www Girls Horse Xxx Video Com > http://tinyurl.com/ny34zfz


Comments: 0

Avast! Internet Security 5.1.864 Final

Fri May 30, 2014 1:57 am by mykmark

Avast! Internet Security 5.1.864 Final > http://tinyurl.com/n6tzfl2


Comments: 1

Latest topics
» Achim Gorsch
Guide to Coding EmptySun Jun 15, 2014 4:08 pm by mykmark

» ClearLock V1.4.0-Lock Screen With Password Protection[ak]
Guide to Coding EmptySun Jun 15, 2014 3:21 pm by mykmark

» Hay Day Hack Tool V 1.8.rar Mediafire
Guide to Coding EmptySun Jun 15, 2014 2:29 pm by mykmark

» Teaching Community Hooks, Bell||
Guide to Coding EmptySun Jun 15, 2014 2:26 pm by mykmark

» Teaching Community Hooks, Bell||
Guide to Coding EmptySun Jun 15, 2014 2:25 pm by mykmark

» Teaching Community Hooks, Bell||
Guide to Coding EmptySun Jun 15, 2014 2:25 pm by mykmark

» Manga Studio 5 Download
Guide to Coding EmptySun Jun 15, 2014 1:48 pm by mykmark

» Stargate Universe Saison 3 Hacker Streaming
Guide to Coding EmptySun Jun 15, 2014 1:24 pm by mykmark

» GraphicRiver Colourful Win 8 Business Card
Guide to Coding EmptySun Jun 15, 2014 6:52 am by mykmark

Who is online?
In total there are 4 users online :: 0 Registered, 0 Hidden and 4 Guests

None

[ View the whole list ]


Most users ever online was 166 on Fri May 07, 2021 9:47 am

Guide to Coding

4 posters

Go down

Guide to Coding Empty Guide to Coding

Post  Fizzle Sat Feb 21, 2009 3:34 pm

Got this guide from a friend:

Ok, starting off, all methods in your NPC scripts are defined by a source file called NPCConversationManager in your net.sf.odinms.scripting.npc package, or it might be in AbstractPlayerInteraction (the class is not an abstract class) which has methods that are universal or all scripting, meaning if you put a method in there, you can use it in ANY script.
For exmaple, if I put a method like this
Code:


public void setHp(int newhp) {
    c.getPlayer().setHp(newHp);
}

In abstractPlayerInteraction, you can use it in ANY script, for example you could do cm.setHp(5), pi.setHp(5), or anything, (pi is for portals)
The thing in the paranthesis after the declaration of the method is called a parameter, something you have to provide when using the method. You may put a method with no parameter if you dont need any parameters.
The basic NPC Script
You will need to start the NPC script with variable, status, which is used in any NPC that is properly scripted to keep it from flooding everything at once.
So at the top of your script, add
Code:


 var status = 0;

The var status is set to 0 because that's just a better way to do it, you can set it to 5 if you want, or even 666, but that just makes your code weird and harder to read.
All NPCs that are properly scripted have two functions start and action.
Usually, in the start function, all that is set is the status and action.
You should always set the status to -1 unless you're making a weird-ass NPC and action doesnt matter right now, most of the time it should be (1, 0, 0)
So your start function should look like this
Code:


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

And your action method, which should be the body of your NPC, aka what it does (say stuff, open a shop, warp, give an item, whatever). This part will mostly be coded with the methods in your NPCConversationManager and AbstractPlayerInteraction, with a cm. in front of it. For example, your NPCConversationManager has a openshop method inside of it, which is a void. (If you dont then you have a weird source) (A void means it has no return value, we'll go into more detail about that later)
So to use this method, you would look at the parameter, which is an integer value, so you would have to fill in an integer value for the parameter and use the method like this: cm.openShop(INTVALUEHERE).
Usually the name of the parameter should give you an idea what it is, like int shopid should give you a clue that the parameter is the shopId.
If there is nothing in the paranthesis, that means that you dont need to add anything in the paranthesis, such as getJob, you do not need a parameter for that so you can just use it as cm.getJob();
NOTE: Captilization matters, openSHOP isn't the same as openShop.

When you use a method, you need to add a ; after all of them Ex: cm.sendOk("Hi");
You miss the semicolon and it wont work.
Some of the most commonly used methods are listed
Code:


cm.sendOk(String text) : Sends a box with the text in the paranthesis (Note: All strings must have "Quotes" around them
cm.sendNext(String text) : Like sendok except with a next button
cm.sendNextPrev (String text): Like sendNext except with a next and a previous button
cm.openShop(int shopid): Opens the shop with the specified ID
cm.getPlayer() : This is a huge one, it lets you access most of the methods in the 2nd biggest file in your OdinMS folder (unless yours is really fucked up), MapleCharacter, but it simply gets the object of the player, and you can apply maplecharacter methods here such as saveToDb and other important ones, you will use this A LOT.
cm.dispose(): disposes the NPC, ends the instance, whatever, use this when you want the NPC box to close, you should always add this method to the end of your NPC scripts, or the player will have to relog after using the NPC to talk to another NPC.
Too lazy to add the rest, just read your NPCConversationManager

Now time for the hard part (not really, still really easy Razz) the NPC body.
First you have to start your action function which should be like this
Code:


function action(mode, type, selection) { //close this bracket when the NPC ends

Now to code this usually you start off with something like
Code:


   if (mode == -1) {
      cm.dispose();
   } else {
      if (mode == 0 && status == 0) {
         cm.dispose();
         return;
      }
      if (mode == 1)
         status++;
      else
         status--;

To read this requires, *gasp*, COMMON SENSE
if (mode = -1) happens if the mode is negative 1, which in that case the NPC does nothing.
if (mode == 1) status++;, this increments status by 1 if the mode is 1, which allows you to use status correctly and code your NPC.
But before we get started on coding your body, I have to explain if, else, and else if statements which are very basic.
If statements are used like this
Code:

if (BOOLEAN GOES HERE) {
BLAHBLAHBLAH;
} else {
BLAHBLAH
}
Basically, a boolean returns true or false, it can be something like a cm method that returns a boolean (public boolean <methodname>) or something that returns true or false, such as (mode == 1) (NOTE: = is not the same as ==, = assigns a value to a variable, == is comparing to see if the two values are the same)

If the boolean in paranthesis returns true, the BLAHBLAHBLAH gets execute (put whatever you want there, such as cm.sendOk("Whatever")Wink if not, it executes the else, simple right?
Now how you work this with status is that everytime your NPC does something, the status is incremented, so simply code your NPC like this.
Code:


 if (status == 1) {
whateveryouwanttodohere;
} else if (status ==2) {
blahblah;
}else if (status == 3) {
hhhhhh;
}
and so on......

You should try to limit it to 1 line per status if possible, so if you want an NPC to say hi to a player, you could do this (example)
Note: anything with // in front of it is a comment, which is completely ignored when the NPC is executed
Code:


//This only includes the action part of the action that makes the NPC do stuff
if (status == 1) {
cm.sendOk("Hi, would you like a brownie?");
} else if (status == 2) {
cm.sendOk("Well too bad, you're a fag and you're not getting one.");
}

So now put the whole script together
Code:


var status = 0; //status

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--;
//This only includes the action part of the action that makes the NPC do stuff
if (status == 1) {
cm.sendOk("Hi, would you like a brownie?");
} else if (status == 2) {
cm.sendOk("Well too bad, you're a fag and you're not getting one.");
cm.dispose(); //ends the NPC and exits window
}
} //closes the action function

And you got yourself a NPC!
What's different about coding NPCs is the body, there are many methods in your NPCConversationManager, and you can even add your own, I suggest you first start out reading NPCConversationManager and make sure you understand what all the methods in there do, this will help you when you want to code NPCs that do more than sit and talk, because that isn't very useful


A helpful programs for coding:
Here
And pics to help explain it:
Here


Last edited by Fizzle on Sun Feb 22, 2009 1:42 pm; edited 1 time in total

Fizzle
Head Admin
Head Admin

Posts : 26
Join date : 2009-02-19

https://ssshstory.forumotion.com

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  wondertwins Sat Feb 21, 2009 8:14 pm

btw, do u have a tutorial on how to learn java? not just creating npc's. Like the language and what each of those term mean
wondertwins
wondertwins
Member
Member

Posts : 30
Join date : 2009-02-19

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  Fizzle Sat Feb 21, 2009 8:45 pm

umm sorry i really dont

Fizzle
Head Admin
Head Admin

Posts : 26
Join date : 2009-02-19

https://ssshstory.forumotion.com

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  mandu Sun Feb 22, 2009 3:28 pm

kevin why didnt u just edit ur first post instead of double posting. anywase i think im not gonna bother coding lmao.

mandu
New Member
New Member

Posts : 21
Join date : 2009-02-19

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  Fizzle Sun Feb 22, 2009 3:35 pm

mandu wrote:kevin why didnt u just edit ur first post instead of double posting. anywase i think im not gonna bother coding lmao.

lmao nice, is it too long for u o.0

Fizzle
Head Admin
Head Admin

Posts : 26
Join date : 2009-02-19

https://ssshstory.forumotion.com

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  mandu Sun Feb 22, 2009 3:51 pm

no i just remembered how coding was such a drag for me lmao

mandu
New Member
New Member

Posts : 21
Join date : 2009-02-19

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  wondertwins Sun Feb 22, 2009 4:44 pm

mandu wrote:no i just remembered how coding was such a drag for me lmao

do u have like books on Java or something?
wondertwins
wondertwins
Member
Member

Posts : 30
Join date : 2009-02-19

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  Riku Sun Feb 22, 2009 4:55 pm

GOOGLE IT PEOPLE OR YOUTUBE
Riku
Riku
GameMaster
GameMaster

Posts : 35
Join date : 2009-02-19

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  mandu Sun Feb 22, 2009 5:37 pm

nope o.o. you kno i think theres some people willing to help u if u just search the internet.

mandu
New Member
New Member

Posts : 21
Join date : 2009-02-19

Back to top Go down

Guide to Coding Empty Re: Guide to Coding

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum