Gw Temp


Tutorial - 'Talking NPCs' by The_Pup

An item about RPGMaker 2000 posted on


Tutorial for having player interaction with NPC objects


The RPG Made Easy in Game Maker: Talking NPCs
The tutorial for making a player interaction with NPC objects.

By Shaun "The_Pup" Campbell(with thanks to Ryan and Yugi for their tutorials)

What you need:
Game Maker 5
Medium to little knowledge of GML

1. Make a sprite and then an object for the player(name it Shaun(I have a big ego)) that can move in all directions and make it move with under KeyPresses. Then place on the map.

2. Make objects bob, janessa, michelle(all lowercase just in case) and give each of them a respectable sprite. Then place them on the map. There is no need to give them any actions unless you want them to move around.

3. Make a sprite that is 580 width and 144 height and name it "text_box"(without the " "). Then make a sprite that is 20 width by 20 height and name it "text_more"(without the " "). Sprite text_more should be an arrow pointing to the right or down. Text_box should be decorated a little around the edge or the whole thing.

4. Add a script. Call it "dialog_box"(minus the " ") and type in:

font_size = 20; //Size of the font
font_style = fs_bold; //The font is bold
font_color = green //The font's color is green
draw_sprite(text_box,0,32,10); //Show textbox
draw_text(43,20,argument0); //Text line 1
draw_text(43,58,argument1); //Text line 2
draw_text(43,96,argument2); //Text line 3
if(argument3) //If 1 then show text_more, if 0 then don't
keyboard_wait(); //Wait until a key is pressed

5. In the Step Event of Shaun make action Execute a Piece of Code and place this in it:

if keyboard_check(vk_enter)

if place_meeting(x,y,bob)
dialog_box('Bob','Hello Sir.','What is your name?',1)
dialog_box('Bob','Haha!','You are the great Shaun!',0)

if place_meeting(x,y,michelle)
dialog_box('Michelle','I am depressed...','Do you have any chocolate?',0)

if place_meeting(x,y,michelle)
dialog_box('Janessa','Hello!','I am very talkative!',1)
dialog_box('Janessa','People say I should shut up','But why should I?', 'Oh yeah...',1)
dialog_box('Janessa','Oh I am too loud...','Guess I better be quiet...',0)


6. Test the game and see how it works. Move Shaun to the character and press Enter then press any key to move to the next page. Move to stop talking. Do thi until you are bored or want to see the explaination.


dialog_box script is the heart and is controlling the text with arguments. The script you put in Shaun's Step Event says that if you press key Enter then I will perform an action based on what NPC I am touching.

Let's look at Bob for Example:

{ //Start Block(needed)
if place_meeting(x,y,bob) //If I meet object "bob" at these coordinates
dialog_box('Bob','Hello Sir.','What is your name?',1)
dialog_box('Bob','Haha!','You are the great Shaun!',0)
} //End Block(needed)

Bob's Talk Broken down:

[script] [a0] [a1] [a2] [a3]
dialog_box('Bob','Hello Sir.','What is your name?',1)

Script - Tells what script to use for the arguments.
a0 - argument0 this is Showing the name in the textbox but could be used for talk.*
a1 - argument1 this is talk.*
a2 - argument2 this is more talk.*
a3 - argument3 this is special and has to be assigned number 1 or 0. 1 to show text_more and 0 not to. This is for people to know if there is more text or none.

*WARNING! Avoid any words that have apostrophies in them(ie: I'd, Vivi's, why'd) instead you should go around it or be creative(horrible word sometimes)!

Well that's it! If you wan't to make more then do so!