Hello, citizens of intfiction.org! Sorry I didn’t introduce myself earlier, I kinda made this account at the last minute and didn’t have time to set it up all the way. Short intro: I am an aspiring hobbyist IF author with high-functioning Autism and i LOVE text adventures! I make stuff in Inform 7 almost every day to practice for a big project I have in mind.
Now, here’s my question.
I want to create an IF where the player has access to a list of magic spells that do different things depending how they’re used, in the style of an old text adventure called Enchanter. Anyone familiar with that game? FROTZ makes things light up, NITFOL lets you talk to animals, REZROV opens locks, OZMOO will bring you back if you die a certain way, etc…
How would I go bout writing my own spells for my game and their appropriate functions?
Instead of strange acronyms I want to give them actual, simple one-or-two word names.
Here’s some examples:
SUMMON - Use this along with the name of a familiar or other magical creature you know of to call them to you.
NOLOCK - Like Enchanter’s REZROV, opens or removes the lock on a door or other object.
FEATHER - Put a living person or creature to sleep. UNFEATHER will wake them up, or you can let them wake up on their own.
PAWSPEAK - Talk to an animal, like Enchanter’s NITFOL.
MISTCHIME - Make yourself or someone else calm down. Works only if you or someone else is already experiencing some form of anxiety.
I’d love some advice, thank you fellow authors!
PRESS BOOKMARK BUTTON, EXIT BUTTON
What you need to do is make a separate action for each spell. If you’re unfamiliar with actions, they’re basically the things the player can do in a game, like TAKE something, GO a direction, PUT something IN something, etc. You should go over Chapters 7 & 12 in Writing with Inform. That’ll set you on your way. Come back if something doesn’t make sense.
Right: Enchanter spells are essentially unique verbs. You can OPEN CHEST and you can REZROV CHEST.
You essentially need to write rules just like you would for a verb, and it’ll save you headaches if you write a Check-catch all for everything else.
Check nolocking something (called target) (This is the nolock spell is pointless here rule):
if target is not openable:
say "[The target] doesn't open, and that spell fizzles." instead;
if target is not locked or target is not lockable:
say "Pointless; [the target] is not locked!" instead;
if target is open:
say "Time-space wavers and gives you a metaphorical eye-roll as [the target] is already open. Don't go around wasting mana like that." instead.
Phil and Hanon have the right of it – in terms of their effects, these are all just actions so you’d code them the same way you would any other action, and the examples in the documentation should work just fine. If you’re following Enchanter, the main difference would be that the player would need to find a scroll and memorize the spell on it before it’s available to them, but that should be pretty straightforward too.
If you’re looking for specific examples on that, Scroll Thief is a recent-ish Inform 7 game that implements the Enchanter magic system, and its source code is freely available – if you go to that page, you can both download and play the game to see how things are set up, and check out the source text link to see how it’s all implemented. So that might be a good resource. And of course if you run into particular problems implementing any specific piece, this site is a great resource and folks will be glad to help out. Good luck with the game!
Thank you everyone, I have written this all down in a notebook and stored it safely for future reference!
Yep, the original implementation of Enchanter handled every spell as its own verb. You can definitely do it that way in I7 if you want.
An alternative is how I did it in Scroll Thief (linked above), which is based off a work by Graham Nelson (creator of I7) called Reliques of Tolti-Aph. This involves making spells into a kind of value, and then having a “casting it at” action that applies to one spell and one visible thing.
The benefit of this is that you can put all your general-magic-things code (like not being able to cast a spell without learning it first) in the “check casting” rules, rather than needing to apply them separately to each spell verb.
The downside, of course, is all spells have to have the same grammar. In Scroll Thief, this grammar is “can be cast at a thing or at nothing; if you aim it at nothing, it affects the location”. If you want only the ZIFMIA spell to apply to things the player knows about rather than things the player can see, well, that’s going to become difficult. (I ended up doing some parser magic to make this one work.)
You can find all the implementation details in Volume 0.5, Book I.