RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
Interaction with characters edit: (and game objects)
 
Post new topic Reply to topic Goto page 1, 2, 3, 4, 5, 6  Next 
View previous topic - View next topic  
Author Message
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 8:26 pm    Post subject: Interaction with characters edit: (and game objects) [quote]

To nephilim: I was really impressed with sacraments. Did you really make that whole thing in a month?? Jesus

To anyone: Anyway, I was wondering about how to interact with characters. I was playing sacraments for a while, and something finally clicked within me. Every time you talk to someone/something you have different interactions.

I was just wondering how you would go about doing something like that, or better yet, how the creator did that for his game.

And I guess it goes along with game progression. I've never really done this before, so I have to question how it's done.

Do you basically code the game with different functions and if statements to see where the character is in the game? How can you tell how to play what sequence and when?

Thanks,

Jason


Last edited by Gardon on Mon Feb 06, 2006 8:59 pm; edited 1 time in total
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 8:54 pm    Post subject: [quote]

And what language did you code it in nephilim?
Back to top  
Ninkazu
Demon Hunter


Joined: 08 Aug 2002
Posts: 945
Location: Location:

PostPosted: Mon Feb 06, 2006 9:12 pm    Post subject: [quote]

The trick is in the scripting language. Say you finish a quest. Part of that script sets a variable that says that the quest is finished. When you talk to an NPC, his script can check to see if that variable is set, and if it is, he'll say something else. I suggest you look into scripting. It's a huge paradigm.
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 9:22 pm    Post subject: [quote]

I'll most definitely research scripting. However, can I use existing languages and incorporate them into my C++ programming or do I have to make up my own?
Back to top  
RuneLancer
Mage


Joined: 17 Jun 2005
Posts: 441

PostPosted: Mon Feb 06, 2006 9:23 pm    Post subject: [quote]

What I do is create an NPC object which basically inherits from the Sprite class and the Event class. This NPC has a method called when the player attepts to interact with it.

The sprite class contains the necessary rendering information for the sprite (lil' detail unrelated to your question, really.) It also contains a movement script which basically dictates how to move (could be as simple as "wander around randomly" or as complex as "walk 10 steps left, go up the stairs, stop, look around, go back down, move down 10 steps, right 10 steps, up 10 steps, repeat.)

The event class, reused in many situations, is the interesting bit. A parser translates an event script into a series of operations the game must perform. For instance, a script may look like this...

If GaveRing = 1
-- FacePlayer
-- ShowMessage "Thanks for finding my ring man!"
Else
-- If InventoryContains(Ring)
-- -- SetFrame(Surprised)
-- -- ShowMessage "Woah dude! My ring! Sweet, thanks!!"
-- -- GaveRing = 1
-- Else
-- -- FacePlayer
-- -- ShowMessage "I can't seem to find my ring. :/ "

This script wouldn't actually be text, rather identifiers and the likes, but that's just an implementation detail. The parser for this is called with this script whenever the NPC object receives a "TalkTo" message (ie, the game tells it, one way or another, that the player tried to interact with it.)

There's no universal way to do this, but that's the basics. Implanting a scripting system can be a bit difficult at first, but many resources are available to parse scripts if you want to avoid putting effort in that. LUA, I heard, is good for this. Never used it though...

Not sure if that answers your question about interacting with NPCs...
_________________
Endless Saga
An OpenGL RPG in the making. Now with new hosting!

Back to top  
LeoDraco
Demon Hunter


Joined: 24 Jun 2003
Posts: 584
Location: Riverside, South Cali

PostPosted: Mon Feb 06, 2006 9:27 pm    Post subject: [quote]

Either: certain languages --- such as Lua, or Python --- should be embeddable within other languages. There also exist parsers for given languages --- such as XML --- which are fairly easy to use in certain languages.

However, the benefit of creating your own scripting language is two-fold: first, it becomes finely tailored to your application, so that it does exactly what you need it to --- if you need some new functionality/syntax, it is easy to extend your language to do that (something that not all pre-fab languages support); second, it exposes you to a whole different set of program designs ideas, which, in turn, makes you a better coder. However, this is slightly more difficult --- especially because you are designing a language, on top of implementing that language.
_________________
"...LeoDraco is a pompus git..." -- Mandrake
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 9:35 pm    Post subject: [quote]

Where would I keep the scripts? I mean if I have hundreds of different objects in-game, how would I manage everything?

The only thing I can think of is to make some sort of database that holds all the info needed for the scripts.
Back to top  
LeoDraco
Demon Hunter


Joined: 24 Jun 2003
Posts: 584
Location: Riverside, South Cali

PostPosted: Mon Feb 06, 2006 9:39 pm    Post subject: [quote]

That's up to you: personally, if I only needed a handful of scripts, or I was entirely too lazy to go about setting up a proper database, I would store the scripts in flatfiles in some sort of "scripts" directory in the main project directory. Then, in some easily accessible place in memory --- such as a ScriptsManager aggregator --- I would provide mechanisms for loading, parsing, executing, potentially caching, and even storing scripts.
_________________
"...LeoDraco is a pompus git..." -- Mandrake
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 10:01 pm    Post subject: [quote]

I just pulled up a book of mine:

Programming role playing games with directx


It has a chapter on creating and implementing scripts into the game (they walk you through a role playing game you make in accordance with the book).

I'll look up on that and see what I can come up with, but I think your'e right, making my own would be the best.

Thanks,

Jason Otto
Back to top  
Ninkazu
Demon Hunter


Joined: 08 Aug 2002
Posts: 945
Location: Location:

PostPosted: Mon Feb 06, 2006 10:10 pm    Post subject: [quote]

I have that book and I really wouldn't recommend it for anything. I don't fully remember the part of scripting, but I remember not being impressed.
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 10:32 pm    Post subject: [quote]

What languages do you guys code in?

The reason I'm asking is because I've heard languages like python and C# are extremely easy to develop with.

Maybe I should stick with python or something easier and use C++ for performance demanding situations.

Or should I just stick with C++ forever?

Jason
Back to top  
zenogais
Slightly Deformed Faerie Princess


Joined: 10 Jan 2006
Posts: 34

PostPosted: Mon Feb 06, 2006 10:41 pm    Post subject: [quote]

I personally have coded (simple) games in Python and C++, and want to experiment with Ruby. But for a first RPG I'd say use the language you know best. Picking up another language like Python as you're writing your first RPG is probably not a good thing. As for which language is "best", they're all good, so use what you know. Python can handle the performance demands pretty well I've found, and it is also a very intuitive language, though C++ is obviously faster and works with binary data much easier than Python (i.e. binary map file formats are a horrible pain in Python b/c of Pythons pack/unpack mechanisms).
Back to top  
LeoDraco
Demon Hunter


Joined: 24 Jun 2003
Posts: 584
Location: Riverside, South Cali

PostPosted: Mon Feb 06, 2006 10:41 pm    Post subject: [quote]

C++ is my milk tongue, so I pretty much resort to it for a lot of my projects, mostly because I know it can do everything. However saying, it is important to learn a few different languages. I tend to use PHP for web programming and the occasional script.
_________________
"...LeoDraco is a pompus git..." -- Mandrake
Back to top  
Ninkazu
Demon Hunter


Joined: 08 Aug 2002
Posts: 945
Location: Location:

PostPosted: Mon Feb 06, 2006 10:41 pm    Post subject: [quote]

I haven't really found anything better than C++ that fits my expectations of a good programming language. Python is too slow (MUCH too slow for games), C# is good if you like conforming to M$'s shitty .NET rules and you still don't get cross-platform compatability.

Really though language doesn't matter. Once you really learn the ways of doing things through logic and not just through a specific language, then you'll have the idea of CS down.
Back to top  
Gardon
Scholar


Joined: 05 Feb 2006
Posts: 157

PostPosted: Mon Feb 06, 2006 10:49 pm    Post subject: [quote]

Update:

I now have a scrolling background. I was getting anxious so I just basically slapped it in there to see if it would work and it did! Regardless of the fact that the enormous map takes up 117 MB of memory, it looks and scrolls good :)

Now my next step is to be able to cut and paste in maps. What I want to do is be able to scroll (which I'm doing now) from one map to another seamlessly. It shouldn't be a problem.

I did have one question though. Do you guys ever experience a character moving in one direction faster than in another, when your input speeds are exactly the same?

For example, he moves left twice as fast as he does right.
The scrolling only works in fullscreen mode too.

I don't know, kinda odd questions to ask but if you have any info let me know,

Thanks,

Jason


Last edited by Gardon on Thu Feb 09, 2006 10:42 pm; edited 1 time in total
Back to top  
Post new topic Reply to topic Page 1 of 6 All times are GMT
Goto page 1, 2, 3, 4, 5, 6  Next 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum