Harry Potter style magic system in Inform 7

Hello all, this is my first post, so I hope that everything is correct. I am also new to Inform, so please let me know if this topic is too advanced.

I am trying to create a Harry Potter style magic system in Inform 7, but I don’t know where to begin.

The player would be able to cast spells from a list of their known spells (no mana or anything). This list would grow throughout the game. The command to cast a spell would be “cast [spell] on [thing]” (the [thing] would be omitted if the spell is not cast on anything in particular.

How would I go about doing this, and where should I learn more about magic in Inform?

Thanks!

One thing I can recommend if you’re up to it: Graham Nelson wrote an example game called The Reliques of Tolti-Aph which demonstrates a small RPG that includes dice-rolling and a simple magic system. Be aware this is a very early version of Inform, but includes learnable spells. Since Inform source texts are so readable it might give you an idea how things might be structured, and the code is well-annotated:

Source Text: Graham Nelson - The Reliques of Tolti-Aph — 1 of 57

Another game you might want to check out is @Draconis 's Scroll Thief which re-creates Infocom’s magic system for the Enchanter trilogy with learnable spells used as verbs, so the player can say CAST FROTZ ON SWORD or just FROTZ SWORD.

3 Likes

Disclaimer: I have no actual experience coding in Inform or any IF-oriented language.

Considering the wide range of things magic can do in the Potterverse, my intuition is that it would probably be simpler to treat each spell as its own verb than trying to make all of the spells arguments to a unified cast verb.

Also, unless having that Harry Potter flavor is vitally important to the game you’re making, it might be a good idea to have spells as English words instead of pseudo Latin incantations, or at least include such as synonyms(e.g. Levitate instead of Wingardium Leviosa, Summon instead of accio, repair instead of repairo).

2 Likes

Side note: the implementation of magic in Scroll Thief is heavily based on Reliques of Tolti-Aph, which is why they both have spells as an enumerated kind of value, and an “effect” rulebook to determine what a spell does. I think it’s a solid system for this sort of thing.

Here is where the magic implementation starts, and here is where it ends. Most of this is game-specific complexity you won’t need, but I think it makes a decent example!

5 Likes

Agree with everyone else above, the generalisation of the problem is “verb-based magic system” (the oldest one…); there’s also the “noun-based” one (CAST+spell name), but being a supporter of the *nix philosophy I favour the former…

Best regards from Italy,
dott. Piergiorgio.

If you wanted to use that “cast [spell] on [thing]” command then one way you could do that would be to implement it as a topic listed in a table of known spells. Learning spells adds new entries to the table (or the spells are cross-referenced against a list of known spells). In the documentation, there are numerous examples of conversation implemented this way— look at section 16.13.

2 Likes

Interesting suggestion, because together with a modified hybrid conversation (or even hybrid choice) extension can allow an “interactive spellbook”, along the line:

> CAST
[spells in the spellbook menu]
on which/who ?
> [TARGET]

Best regards from Italy,
dott. Piergiorgio.

2 Likes