Sign in to follow this  
ZackHeckman

Would like suggestions for scripting

Recommended Posts

So as I've been working on various games in my time I feel like I should have a scripting tool / engine. My idea here ( and I mostly explain this through example because I'm not quite sure what I'm looking for ) is to have like a C# tool that lets you write scripts but I mean writing now why wouldn't I just like write them in a .txt and .... idk maybe someone here has an idea lol. The whole concept is to instead of mass producing .cpp's and classes or extending a CEnemy class to 500,000,000 lines of code to contain all the enemies AI and behaviors or even the same with like items in the game, have a scripting engine and tool to quickly and easily produce enemies and weapons. The game is being written in XNA and I'm basically looking for the most efficient way to do content creation that is not a million classes. I realize I said cpp earlier even though it's XNA but I hope in some way during this rant I've explained my problem that I'd love suggestions for. I want to write some sort of scripting engine for this because I believe that'd be the best way to create content but if I'm wrong someone please suggest something I'm all ears and would love to hear all suggestions. Sorry for the wall of text :(

Share this post


Link to post
Share on other sites
Yeah, you idea is quite correct and I believe it's common used in the gaming industry. :)

But, why write your own script engine? You are wasting your time.
There are bunch of existing great script engine.
I recommend you have a look at Lua, it's popular in game development, and very simple to use, also simple to bind.
If you don't mind heavy script engine, I really like Javascript, there is great Google V8 engine (300K line of code though).

Share this post


Link to post
Share on other sites
Oh no absolutely not, I am by no means trying to write my own scripting engine. I'm not a big fan of reinventing the wheel. I'm wondering like what would be a good solution to the problem that is hundreds and hundreds enemies weapons obstacles and items in a game without having to hard code it all recompile every time and just generally suck in that aspect lol. Like if I wanted to write a fireball spell and actively test it without having to recompile the game what's the best direction to head in?

Share this post


Link to post
Share on other sites
Data-driven design. Build code that can handle general case projectiles (launch, travel, payload, etc...) then feed the system data to represent a fireball, including fireball animations and a script to describe what happens when the fireball hits. Write code to instance a general monster, then feed it the data for a hundred thousand specific monster instances.

In a data-driven approach, you don't hard-code anything. Everything is representable as data, and the program simply operates on that data. One aspect of embedded scripting languages such as Lua, as far as data-driven is concerned, is the idea of code-as-data. Since the script is interpreted, entity behaviors can often be written as script code rather than hard-coded into the engine. The engine provides the hooks and such, the script provides the data that describes the behaviors in terms of the hooks into the code.

Share this post


Link to post
Share on other sites
Alright so what I hear is the problem is that XNA recompiles all files regardless of type at runtime anyways so even if I were to change a script the game would have to recompile. I guess with that being said is there any sort of solution that is the effectiveness of scripting that I'm looking for as described by JTippetts that works with XNA?

Share this post


Link to post
Share on other sites
I was talking about using C# to make a tool to write scripts which would be exported into XNA, not scripting for a C# game. There is no real reason to write a tool in C# though, notepad works just fine I was just overthinking.

Share this post


Link to post
Share on other sites
If you write your behavior stuff in .DLLs then you dont have to recompile the whole game ....

Of course whether its classes or equivalent one way or another you have to organize your
behavior logic somehow (even if its nebulous blobs that get called thru standardized passed data interfacing)

I went the way with DLL with native C/C++ on some projects (LUA and other scriting is 10X or more times slower than natively compiled
code but that may not matter for your project, but did very much for mine)


I looked at TinyC ( [url="http://bellard.org/tcc/"]http://bellard.org/tcc/[/url] ) as an imbedded compiler/scripting type usage but later just decided to use the DLL with
regular full strength C/C++ compilers instead.

The scripting languages can sometimes be easier to 'code' but I found that most of the behavior stuff I was doing was mostly subroutine calls
and standardized data inside the AI framework and relatively simple logic that even alot of the fancier features of most scripting languages wasnt used anyway.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this