Page 1 of 1

Making An RPG Character With Responses

Posted: December 24th, 2009, 1:51 am
by Chaze007
I'm going to teach you how to make an RPG Character with Responses.
As all of you coders/pre-coders should know, // = commenting. That means that line of text doesn't affect anything.


WARNING: This script was made in/for the Developer's SVN Version. This script MAY NOT work in the 2.4

spawn_RGuard = [
//This is the name of the spawned character it will be used ingame as /spawn RGuard
r_name "Fort Ruik Guard"
//The character's actual name
r_model "rpg/characters/npcman"
//The character's model

r_interact [
r_face $rpginterract
//Makes you face the spawned character
r_select $rpginterract
//Makes you select the spawned character
r_face $rpgself
//Makes the spawned character face you
r_talk $rpgself
//Initiates the talk sequence
]

r_say "Yes Citizen? Speak quickly, I am a busy man." [
//0 the first line of r_say always starts off as 0 and goes down. r_say = what the spawned character says and r_response is what you can choose from.
r_response "Can I ask you some questions?" 1
//this option goes down to the first line of r_say basically the 1st gui of text.
r_response "[Leave]" -1
//this option ends the chat.
]
r_say "Make it quick citizen." [
//1 the second line of r_say
r_response "Do you know of a place to rest?" 2
//Goes down to the third menu. Catching on yet? 0=1 1=2 2=3 etc.
r_response "What is this place?" 3
//This brings you to the fourth option.
r_response "Where can I buy supplies?" 4
//This will bring you to the fifth option, catching on?
r_response "Nevermind, Goodbye!" -1
//exits the chat.
]

r_say "The White Wyvern is a tavern known for it's variety of drinks. It's the place to go if you're looking for a night out." [
//2 third line of r_say
r_response "Can I ask you something else " 1
//brings you back up to the second line or r_say
r_response "Alright thanks! Goodbye." -1
//exits chat
]

r_say "This is Fort Ruik, a training grounds for militia men. Fort Ruik is also a resting place for travelers and merchants." [
//3 fourth line of r_say
r_response "Can I ask you something else?" 1
//brings you back up to the second line or r_say
r_response "Thank you, Goodbye!" -1
//exits the chat.
]

r_say "The Golden Hammer is a militia man's store, they sell everything from swords to bows, although I do believe they are out of stock at the moment." [
//4 fifth line of r_say
r_response "Do you know when the next shipment will be in?" 5
r_response "Can I ask you something else?" 1
//brings you back up to the second line of r_say
r_response "Alright thanks! Goodbye." -1
//exits the chat.
]


r_say "The next shipment is due within 3 months." [
//5 sixth line of r_say
r_response "Can I ask you something else?" 1
//brings you back up to the second line or r_say
r_response "Thank you, Goodbye!" -1
//exits the chat.
]
]
Now that you've got all of that covered, you shouldn't need the commenting to help you along the way. Here's the same code, without the commenting help.

Code: Select all

spawn_RGuard = [
	r_name "Fort Ruik Guard"
	r_model "rpg/characters/npcman"

		r_interact [
		r_face $rpginterract
		r_select $rpginterract
		r_face $rpgself
		r_talk $rpgself
		]
		
	        r_say "Yes Citizen? Speak quickly, I am a busy man." [ //0
		r_response "Can I ask you some questions?" 1
		r_response "[Leave]" -1
	]	
			r_say "Make it quick citizen." [ //1
		r_response "Do you know of a place to rest?" 2
		r_response "What is this place?" 3
		r_response "Where can I buy supplies?" 4		
		r_response "Nevermind, Goodbye!" -1
	]
	
	        r_say "The White Wyvern is a tavern known for it's variety of drinks. It's the place to go if you're looking for a night out." [ //2
		r_response "Can I ask you something else " 1
		r_response "Alright thanks! Goodbye." -1
		]			
		
		    r_say "This is Fort Ruik, a training grounds for militia men. Fort Ruik is also a resting place for travelers and merchants." [ //3
		r_response "Can I ask you something else?" 1	
		r_response "Thank you, Goodbye!" -1
	]
	
			r_say "The Golden Hammer is a militia man's store, they sell everything from swords to bows, although I do believe they are out of stock at the moment." [ //4
		r_response "Do you know when the next shipment will be in?" 5
		r_response "Can I ask you something else?" 1			
		r_response "Alright thanks! Goodbye." -1
	]
	
	
			r_say "The next shipment is due within 3 months." [ //5
		r_response "Can I ask you something else?" 1			
		r_response "Thank you, Goodbye!" -1
    ]
 ]	

Re: Making An RPG Character With Responses

Posted: March 2nd, 2010, 10:52 am
by malkin61
This looks good but I' having trouble grasping some things - just started using Sandbox - trying th develop a rpg.

1. Where does the code actually go? I've tried adding it to my cfg file but nothing happens.
2. How do you define where your npc is located in your map?

Thanks in advance

Malk

Re: Making An RPG Character With Responses

Posted: March 16th, 2010, 12:12 am
by carter472
You just put the code into your cfg.

Then when you're in the game, you go into edit mode by pressing F1, and you spawn the model.

For example, in edit mode, you type /spawn RGuard

That would spawn the exact model specified by the code and all its conversations will be available.

This also allows you set wherever you want the RGuard to be spawned.

Re: Making An RPG Character With Responses

Posted: March 16th, 2010, 3:44 pm
by malkin61
Ok - I'm getting there.

I copied your code into the cfg file. Started my map in RPG, hit F1 and typed /spawn RGuard.

Good news - the new npc appeared. Bad news - there's no interaction. It doesn't turn to face me or communicate anything. I mean that no dialogue box appeared.

Getting closer! But more help and sorry to be a pain with my questions..

Malk

Re: Making An RPG Character With Responses

Posted: March 17th, 2010, 8:55 am
by arcones
The reason he's not talking is because the "r_face" doesn't work in 2.5.... I've tried it and it won't work :|

So until it works, you can try to circumvent that by messing around with the code... (Unfortunately I don't know how :( )

Re: Making An RPG Character With Responses

Posted: March 17th, 2010, 8:42 pm
by Hirato
did you press E when he's your "hover" target?

Re: Making An RPG Character With Responses

Posted: April 7th, 2010, 10:25 am
by Leo_V117
Thats True. Press E when youre facing him and a symbol appears. Then you can talk to him. And as for parts that dont work, apparently, if you type in "r_get" as a replacement for "r_" in the rpg_game.cfg, in the console during the game, it should give you an example of how to impliment that piece of code. Is that true or just a rumor?

Re: Making An RPG Character With Responses

Posted: April 7th, 2010, 4:24 pm
by klimyriad
i just put this in my game if that is okay with you
Of course i change it a little bit

Also i put it in my forums too to show off your work on 3adstudios go and check it out if you want

http://3adstudios.darkbb.com/general-f7 ... t19.htm#19

Re: Making An RPG Character With Responses

Posted: April 7th, 2010, 4:29 pm
by Leo_V117
What work? Ive done something that i dont remember doing. Shed some light on it please.

Re: Making An RPG Character With Responses

Posted: April 7th, 2010, 4:42 pm
by klimyriad
sorry Chaze007 i will correct that but still your shop scripted is on the website and Leo i will change it sorry Chaze007

I still put this scripted on the website it was because i was reading your shop scirted and i gor confused when i was here oh well
It is night and i am tired and make mistakes i think i need to go to bed see ya all

lol