Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

The goal is to be able to create complex spells, that can manipulate the game's environment in non-preprogrammed ways, and to make the program understand spells. For example:

$@

$=Big
@=Fire

You can probably understand what this one means. The player types, writes, or selects symbols. Of course, a spell can be only a few characters, or more sophisticated spells could potentially be hundreds or thousands of symbols long.

How could something like this be accomplished?

share|improve this question

closed as not a real question by Trevor Powell, Sean Middleditch, Josh Petrie, Byte56, Nick Wiggill Dec 9 '12 at 10:33

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What is the confusion you're having, exactly? You want your players to type thousands of symbols? –  ssb Dec 9 '12 at 5:19
    
I think that maybe a couple examples of several-thousand-rune-long spells would be helpful. Perhaps we're all misunderstanding since your only current example is only two runes long, with one being an adjective and the other a noun, which makes it pretty obvious and straight-forward to implement in a way that might not be appropriate for what you're actually thinking about. –  Trevor Powell Dec 9 '12 at 5:27
    
I believe Deathly is just pointing out that such a system could potentially support spells with thousands of symbols. He is not saying every spell would be thousands of symbols long, but more advanced ones could be. He is curious about how such a magic (and spell interpretation) system could be accomplished. –  Jonathan Hobbs Dec 9 '12 at 5:50
    
@Deathly I've made an edit to your post that I think clarifies some things. Please check my edits and make sure I've still preserved the intent of your post. –  Jonathan Hobbs Dec 9 '12 at 5:52
2  
What is actually being asked for, here? Is Deathly asking for an implementation technique? Or a design for the game mechanics? Or a link to a "programmers for hire" jobs board where he can hire somebody? "How can this be accomplished?" doesn't really tell us what sort of answer to provide. –  Trevor Powell Dec 9 '12 at 5:56
add comment

2 Answers 2

This can be done via programming! As in, for example, Dungeon Master, released way back in 1987, which used exactly this magic system.

There's no trick to this sort of thing. If the user picks "fire", then "big" makes the effect larger. You can do this by a multiplier, by a static amount, by scaling up the area of effect, or whatever. There's no AI involved at all. Just a matter of taking user input and doing something sensible in response to that input.

share|improve this answer
4  
As a player, I can't imagine wanting to string together thousands of symbols in order to cast a spell in a video game. I mean, assuming that "thousands" means just 2000, and that I can maintain a clicking rate of two symbols per second, it would take more than 15 minutes just to enter the symbols for a single spell. Frankly, I'd rather play an XCom mission, instead. Or get zergling rushed twice. Or something like that. –  Trevor Powell Dec 9 '12 at 5:04
1  
Good job Trevor, best answer for 2012. "This can be done via programming!" You have my vote. –  Nick Wiggill Dec 9 '12 at 10:34
add comment

To me it seems you want to deal with the rules of grammars (contextfree, context-sensitive, whatever) which are e.g. also used for designing programming languages.

Then you could define rules for which spells might follow which other spells or which modifiers. This is checked on syntax (correctness according to the rules) first.

Grammars look like this (I will not make it as formal as it is usually, because it might frighten you)

  • We always start with [spell]
  • We can replace [spell] with [sizeof] [basic_spell]
  • We can also replace [spell] with [spell], [spell] (making to spells in a row)
  • We can replace [spell] with [basic_spell]
  • We can repeat these rules several times

This would be a valid grammar and say we have the following basic_spells: fire, water, light

And these modifiers (sizeof): small, big, short, long

We could do something like this:

small fire, long water
small fire, water
big water

But illegal would be something like big short water. Or also angry fire, because there is no word angry in our set.

Of course you can replace the long words with single characters.

Later you will have to check it for semantics (meaning), e.g. if somebody uses a fire spell and then a water spell, it would reduce the overall power of the spell (Baten Kaitos uses this system). So big fire, small water would reduce the power of this spell, because water stops fire.

One the whole you could search for how programming languages are designed, because creating a new syntax for spells is nothing different. Maybe start with finding out how brainfuck works and search for how compilers or interpreters for brainfuck are programmed. As far as I know it's usually a few steps:

  • checking if all characters are valid
  • checking if the order of characters and words is valid (e.g. foo int is not valid in Java, but int foo is)
  • building a tree from the code
  • traversing that tree to generate the basic commands (in your case the desired spell combination)

Might not be totally correct, as I am not a compiler-programmer.

Depending on how difficult your syntax shall be, you can leave out some of the commands. E.g. my upper example was totally linear. You only had to check if the spell is valid and if it was, combine adjectives and nouns and then execute all commands in a row.

But in programming languages we also have if-conditions and loops (for, while), which leads to non-linear situations. Thus we need a tree which shows us how stuff is related.

In your situation one could think of spells like 4($!) which might mean: Do the spell $! four times.

So you see, it's pretty much parsing a programming language.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.