Yo. I'm working on an RPG engine in C# and XNA. We're planning on targeting Windows and Windows Phone 7, but are running into issues with AI interactions and controlling player actions during cutscenes. FOr the most part, everything is extracted using the MVC design pattern, but obviously would break separation of concerns. So the idea is to have an interface (IScriptEngine) that takes an IScriptObject and updates data in the map model accordingly.
I was thinking about putting the scripts in an XML sort of syntax:
<Script Name="MoveNPC_1">
<Action Command="MoveToTile" Target="NPC_1" Value="10,2"/>
</Script>
And have the engine parse it that way. My biggest fear is performance issues and scalability.
Name:
Anonymous2010-08-22 1:06
>>1
you have at least eleven problems. that's as many time zones as the Soviet Union!
Name:
Anonymous2010-08-22 1:08
>>2
What would those be? I assume performance would be a big one, and placing everything in a giant switch() statement is ugly and horrible, but would be easy.
I'd use LUA or something similar, but WP7 lacks Reflection.Emit, and most .NET based Scripting languages require that.
Name:
Anonymous2010-08-22 1:22
(USER WAS DRUNK WHILE WRITING THIS POST)
let's see: RPG C# XNA Windows Windows Phone 7 MVC IScriptEngine IScriptObject XML (3 lines actual PIG DISGUSTING XML)
(OK, so I don't mind RPG games and I rather like C#, don't really use Windows anymore and don't mind it, try to use MVC whenever possible... but still..)
Name:
Anonymous2010-08-22 1:26
I wish I had a choice on that stuff. It's for a Microsoft Competition. Have to use C# and XNA, and target Windows/Windows Phone. That's why I'm so desperate for a scripting language. Nothing fucking runs on WP7 yet.
Really? It made sense to me. Break up each component into a logical Model, View, and Controller, and work from there. I've never had issues with the MVC Pattern. Any specific reason it's harmful?
>>7
He's just trolling you, bro. MVC is just common sense.
Name:
Anonymous2010-08-22 4:06
>>10
Ah... I feel silly now.
I wish Windows Phone 7 supported CodeDom.Compiler and other sorts of dynamic goodies. This would be so much easier
Name:
Anonymous2010-08-22 4:20
XML isn't really the best to go with, take a close look at the MCP. Very easy to make your own language with it.
Name:
Anonymous2010-08-22 4:44
Real games use only OpenGL and home-brew AI engines which run inner loops in optimized, platform selected assembly.
Name:
Anonymous2010-08-22 7:47
XNA NY ANUS
Name:
Anonymous2010-08-22 9:15
>>1
You need to learn what XML is for. It's a declarative interchange language for computer programs. It is not meant to be hand-written by humans. At least, it really should not be hand-written by humans.
Are you seriously not allowed to just link in a Lua interpreter? If not, then at the risk of sounding like a lispfag, my recommendation would be to make your script format s-expression based. In other words, your example would look like this:
(script move-npc-1
(move-to-tile npc-1 10 2))
The reason this sort of representation is good is because it's absolutely trivial to write a parser and interpreter for it. Seriously you could do this in 100 lines of C#.
>>15
He's using Cocktothorpe and thought XML was a good idea. He will not be able to write a parser for S-expressions.
I bet even figuring out how the provided XML libraries worked was a considerable challenge for him.
>>15 If not, then at the risk of sounding like a lispfag, my recommendation would be to make your script format s-expression based.
I'm not a Lisp fag but I endorse this. Using s-expressions (or the like) will cut out more than half the work.
>>16
Hey, don't be hatin' on >>1 just because he's spent too much time in the ENTERPRISE community.
Still, I don't see a point in creating an IScriptEngine interface; it's not like you're going to have five different ones, right?
And I don't quite understand [>>1's] post. When you say FOr the most part, everything is extracted using the MVC design pattern, but obviously would break separation of concerns. what is it that would break the separation of concerns?
>>19 I understand what XML is for, but markup languages exist (XAML Anyone?)
No, you don't understand the problem at all.
I guess the idea is to have something like Storyboards
I'm assuming ``Storyboards'' is some specific buzzword, rather than the general concept.
You need to take a step back from your Microsoft Enterprise bubble and look at what people who know what they're doing are doing. Enterprise software barely works in contexts where performance doesn't matter (to the point where it's alright if some actions literally take hours); it doesn't translate to games at all.
>>7
MVC is an unnecessary layer of ENTERPRISE bloat that tends to make things more complicated than necessary. Sure, it might've been a good idea for one or two specific cases, but having recently worked on a rather large web application in which everything was separated out like that, I can say it's not worth the hassle of "now where was the code for that..."
You can fully extend classes and use the whole .NET framework from it.
Name:
Anonymous2010-08-23 22:07
>>23
The point of MVC is a concept known as separation of concerns. The overall system is comparatively more complex, but this way encourages greater segregation of tasks which allows greater focus on the components - the parts are segregated and so working on your bit of the system shouldn't require you to care for the internal details of the other parts of the system.
My suspicion is that you or whole team are doing it wrong if you find it comparatively more difficult to understand.
use scheme
no parsing problems. no performance issues.
Name:
152010-08-24 4:32
>>1
Here's a micro lisp manual and related discussion that you might want to use. Some people implement this as a training exercise whenever they want to learn a new language.
With C# this will be especially easy because you can use the underlying platform's garbage collector. Just create a base class lisp object, and subclass it with a cons cell and an atom; then write a simple S-expression parser that takes a text file and builds a tree of cons cells; and then just translate the eval function you see in that paper into C#. Piece of cake. A hundred lines easy.
>>28
That's hardly a modern Lisp, and besides, he doesn't even need to know Lisp to understand S-Expression notation, it's one of the simplest notations ever, compared to modern-day bloated equivalents such as XML.
Name:
Anonymous2010-08-24 5:50
>>29
Why would he need a modern Lisp? He doesn't actually need any modern functions. He probably doesn't even need the most basic things like arithmetic; he just needs to add a few built-ins (like his "move-to-tile" function.)