From The Mana World
< User:Wombat
Revision as of 12:31, 21 October 2009 by Wombat (talk | contribs) (added "random" npc for tutorial)

Here are some basic NPCs that can be used as templates and to learn scripting with. While they use the botcheck map, that is mainly for testing purposes.

Guy

Guy is an NPC you can use for giving information to characters when they question it.

//

botcheck.gat,13,18,0 script Guy	102,{
	mes "[Guy]";
	mes "\"I'm just talking.\"";
	next;
	menu "Good",L_Good,"Bad",L_Bad,"Go on..",L_Goon;
	
L_Good:
	mes "[Guy]";
	mes "\"You selected good.  Good for you!\"";
	close;
	
L_Bad:
	mes "[Guy]";
	mes "\"You selected bad.  You suck!\"";
	close;
	
L_Goon:
	mes "[Guy]";
	mes "\"I'm going to talk for a little bit since you wanted me to go on.\"";
	next;
	mes "[Guy]";
	mes "\"Here I am talking for a second time.  That is if I did this right :D\"";
	next;
	mes "[Guy]";
	mes "\"Here I am talking a third time.  I am running my mouth today!\"";
	close;
}

Dude

This NPC communicates with the NPC "Someone", another NPC. Changing the script can make this a basic message sent and received quest.

//

botcheck.gat,14,19,0	script	Dude	102,{
    if (Dude == 1) goto L_Dude_Notdone;
    if (Dude == 2) goto L_Dude_Done;
    if (Dude == 3) goto L_Dude_Again;
	mes "[Dude]";
    mes "\"Hey, I'm wanting to talk to Someone.\"";
    next;
    menu 
        "I'll talk to him.", L_Talk,
        "I won't talk to him.", L_Notalk;
    close;
    
L_Talk:
    set Dude, 1;
    mes "[Dude]";
    mes "\"Thanks.\"";
    close;
    
L_Notalk:
    mes "[Dude]";
    mes "\"Whatever.\"";
    close;
    
L_Dude_Notdone:
    mes "[Dude]";
    mes "\"I thought you were going to talk to Someone for me!\"";  
	next;
	mes "\"Please do.\"";
    close;
    
L_Dude_Done:
    set Dude, 3;
    mes "[Dude]";
    mes "\"Did you talk to him?\"";
	menu "I did.", -;
    mes "\"Awesome!\"";
    close;
    
L_Dude_Again:
    mes "[Dude]";
    mes "\"Good to see you again!\"";
    close;
}

Someone

//

botcheck.gat,15,20,0 script Someone 102, {
    if (Dude == 1) goto L_Talktodude;
    mes "[Someone]";
    mes "\"Hi there!\"";
    close;
    
L_Talktodude:
    set Dude, 2;
    mes "[Someone]";
    mes "\"You talked to me for Dude.\"";
    close;
}

Jake

Jake gives random equipment for 1000 gold.

//

botcheck.gat,18,15,0 script Jake	102,{
	setarray @Items$, "Bow", "CottonShorts", "Dagger", "LeatherShirt", "Boots", "MinerGloves", "MinersHat";
	set @items$, @Items$[rand(getarraysize(@Items$))];
	
	mes "[Jake]";
	mes "\"For 1000 gold, I'll give you a random item.\"";
	next;
	mes "\"Would you like something random?.\"";
	menu
		"Yes.", L_Yes,
		"No.", -;
	close;
	
L_Yes:
	mes "[Jake]";
	mes "\"Here you go.\"";
	next;
	mes "You get one " + getitemname (@items$) + "!";
	set zeny, zeny - 1000;
	getitem @items$, 1; 
	close;
}