New to scripting?

Content and general development discussion, including quest scripts and server code. TMW Classic is a project comprising the Legacy tmwAthena server & the designated improved engine server based on evolHercules.


Forum rules

This forum houses many years of development, tracing back to some of the earliest posts that exist on the board.

Its current use is for the continued development of the server and game it has always served: TMW Classic.

Post Reply
User avatar
meway
TMW Classic
TMW Classic
Posts: 1737
Joined: 04 Jan 2009, 05:02
Location: Detroit MI

New to scripting?

Post by meway »

Scripting an NPC

Code: Select all

009-1.gat,81,41,0 script Milly 114, {
mes "[Milly]";
mes "\"Hello.\"";
close;
}
[/color]

Above is an example of an NPC saying Hello. This NPC is using multiple Messages. First it says [Milly] Than it says Hello.

1)

Code: Select all

009-1
is determining the map that the NPC is located.
Note: .Gat allows the server to recognize the map

Code: Select all

81,41
is the spot on the grid (using square unites) an NPC will stand while on a map. 1,1 being the very most upper left of the grid.

Code: Select all

,0 
Tells the NPC what way it is facing. This usually will remain 0

Code: Select all

script
is the command that indicates it is a script

Code: Select all

Milly
is the name printed in the client below the sprite (you will see this in game below the NPC sprite)

Code: Select all

114,
is the sprite id to be looked up in client data /npc.xml This file is located in your updates.

Code: Select all

{
indicates the start of a script
2)

Code: Select all

mes
This tells the client to print a message when you click on an npc.

Code: Select all

"
opens a place for you to type the printed message you want your npc to say

Code: Select all

"
At the end of the printed message, this lets the npc know the message is complete

Code: Select all

; 
This is placed after each command to indicate the command line is complete
3)

Code: Select all

mes
refer to number 2)

Code: Select all

"
starts a string

Code: Select all

\"
means there is a " within a string

Code: Select all

Hello.
Is the printed message

Code: Select all

\"
refer to 2 lines above

Code: Select all

"
refer to 2)

Code: Select all

;
refer to 2)
4)

Code: Select all

close 
is a command that allows a player the option to close the prompt while in game

Code: Select all

;
refer to 2)
5)

Code: Select all

}
indicates the end of the script
If I missed anything or you feel the need to edit this Paste-bin via pm and I will credit you for your alterations. I plan on continuing this thread with example npc and eventually creating 1 downloadable document

______________________________________________________________________
Authors: Meway, PjotrOrial
Attachments
screen.png
screen.png (231.62 KiB) Viewed 1760 times
Last edited by meway on 27 Sep 2011, 11:13, edited 1 time in total.
User avatar
meway
TMW Classic
TMW Classic
Posts: 1737
Joined: 04 Jan 2009, 05:02
Location: Detroit MI

Re: New to scripting?

Post by meway »

I would add under Authors the person who created the milly script if I knew who that was.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 16:08
Location: Germany

Re: New to scripting?

Post by Crush »

Hi meway.

Thanks for writing this, but I think that the wiki would be a better place for this than the forum.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
meway
TMW Classic
TMW Classic
Posts: 1737
Joined: 04 Jan 2009, 05:02
Location: Detroit MI

Re: New to scripting?

Post by meway »

If ali-g wants to work his magic I don't mind. But I dislike using the wiki myself so I will have to continue here.
User avatar
Alige
TMW Adviser
TMW Adviser
Posts: 1398
Joined: 09 Jan 2010, 19:22

Re: New to scripting?

Post by Alige »

I personally don't have the time to do this. I already need to do all the magic skills, all the NPCs and translate all that in french, moreover Wombat asked me to add few things on wiki a year ago, and I still didn't do that.

If people want to learn how to script, they just need to connect on IRC, ask some help and use their head.

Good job so far Meway, keep it up,
best regards,
Ali-G
Image
User avatar
meway
TMW Classic
TMW Classic
Posts: 1737
Joined: 04 Jan 2009, 05:02
Location: Detroit MI

Re: New to scripting?

Post by meway »

Post Reply