# What Kind Of Operators or Functions Should A Magic Language Have?

I am going into considerable detail designing a magic language for a game system. The world is a classical high fantasy type world, with most of the tropes that might be expected from old school D&D. The magic system is somewhat unique in that I am designing it around effects, functions, and operators. I have developed what I believe to be a pretty comprehensive list of effects that can be combined in different ways to produce most of the classic "spells" that exist in classical fantasy literature.

Effects will have associated costs in energy (which will boil down to a points system which is not too relevant to this question). A "spell" will consist of one or more "Effects" which can be combined using functions. There is no upper limit to how many effects can be combined into one "spell", but there should be an exponentially increasing point cost as more and more effects are added to a single spell.

My question is: in order to achieve a flexible "language" that can be used to develop many different types of spells with (as of now) 26 "Effects", what operators and functions do I need? Also, I need to ensure that the point cost becomes prohibitive after 4-5 "Effects", and I think I need to associate a cost to the function, which would increase by a multiple of how many functions there are.

I've looked into symbolic logic, but there is a lot of focus on true/false statements, which is not necessarily what I am going after. I am thinking of something more along the lines of a very simple programming language. I do not want something massive and complicated, so what would be the minimum number and type of functions to be useful and flexible?

 In response to queastions: I am looking for some specific things as far as operators. I need to the ability to "add" an effect to a "spell". I need the ability to designate that one effect comes before another one. Conditional behavior would be a good thing. "If this, then X, if something else, then Y". I want to limit the amount of conditional elements embedded in a single spell because I don't want someone to be able to just hit the "this does everything spell" which has basically all effects embedded, so embedding conditions should have a cost. I want the ability to delay an effect: "wait X time before doing Z". I think there are some other basics that I should include just for completeness sake.

[Edit II] In response to comments. Here is what I envision as a use case more or less: "I am a cool adventuring wizard guy in an online game, I found this scroll that has a "Burning fingers of flame" spell on it, I am going to take it to my magic workshop and edit it to create a custom spell. I am going to remove the "burning" component by using a visual scripting type editor in the UI. In it's place, I'll put in a "cold" effect, add a timer function to delay the effect for 3 seconds, and add a "darkness" effect that takes place immediately. Now my custom spell will cause darkness, and then drop a cold frost effect on a target when cast. I'll rename it "Cold Dark Hands" and save it to a scroll.

For reference, my list of "Effects" (these will each represent a "spectrum" from very minor to very major, with point costs calculated on that basis):

1.Force

2.Flame

3.Cold

4.Darkness

5.Change Weather

6.Water

7.Energy Bolt

8.Lightning

9.Transform Caster

10.Transform Target

11.Invisibility

12.Change Size

13.Levitate Target

14.Drain Life

15.Flight

16.Conjure

17.Teleport

18.Curse/Bless

19.Alteration

20.Illusion

21.Conjure Stuff

1. Mind Control

2. Force Field

3. Lore/object read

4. Dispel Magic

5. Light

• You may get some useful feedback to this question over at rpg.stackexchange.com as well? – CaM Feb 8 '17 at 16:22
• Could you give any examples/more detailed descriptions of the functions you would like to end up with? I'm just finding it difficult to picture what the outcome you desire is. – Lio Elbammalf Feb 8 '17 at 16:23
• This is where I immediately think of Powershell - come up with a list of nouns and a list of verbs; your "spell-lets" then become a combination of a verb and a noun, and they can be linked together in several ways to produce the final effects you want. For example, with verbs "Create", "Apply", and "Throw", and nouns "Object", "Projectile", and "Flame", you might get "Create-Projectile | Throw-Object" for the equivalent of Magic Missile, and "Create-Projectile | Apply-Flame | Throw-Object" for the equivalent of Fireball. – Jeff Zeitlin Feb 8 '17 at 16:40
• This may be a very tricky question to answer. The real answer depends on the nature of your game. You want to tune these systems to fit your user. If this is a "casual" RPG, you want this to be quick easy and fast. If so, you might want to actually prune the language down. On the other hand, if you're targetting veterans of EVE (aka Online Spaceships), you will want a very advanced language. Your causal RPG doesn't need to be very balanced, while your EVE targetted RPG will require massive balancing efforts which shape the nature of the language. – Cort Ammon Feb 8 '17 at 16:44
• Also, something that you may have fun with is a hobby of mine: semantic networks. Depending on your user's interface to the spell casting system, it may be an interesting departure point for you to explore. – Cort Ammon Feb 8 '17 at 16:45

## 3 Answers

I'm not entirely sure on what you want but if I have imagined it correctly a psudo-coding interpretation may be something like:

Functions take in the effects and other properties such that you could have a scroll that, in a basic for says:

burning fingers of flame: fingers(fire, burning,0,40)

Where you could have a function for each part of the body and a generalized form may look like: Scroll Title: object( Primary_effect, degree_of_primary_effect, primary_timing, secondary_effect, degree_of_secondary_effect, secondary_timing ...,mana_level)

This function could also take in other features of an effect other than timing, shape, projectile, static, rune...etc

The details of the function would look like:

object( Primary_effect, degree_of_primary_effect, primary_timing, secondary_effect, degree_of_secondary_effect, secondary_timing ...,mana_level): time = 0 whilst(mana_level>0): if time>=primary_timing: if mana_level-Effect(primary_effect,degree_of_primary_effect).ManaCost >0: object.Set.Effect(primary_effect,degree_of_primary_effect) mana_level=mana_level-Effect(primary_effect,degree_of_primary_effect).ManaCost if time>=secondary_timing: if mana_level-Effect(secondary_effect,degree_of_secondary_effect).ManaCost > 0: object->SetEffect(secondary_effect,degree_of_secondary_effect) mana_level=mana_level-Effect(secondary_effect,degree_of_secondary_effect).ManaCost time+=1

Now this doesn't actually give you all the details for how your function performs this task but it could give you the freedom to write the function:

Hand( cold, freezing, 3, Darkness, gloom,0 ,200):

Which, going through the general code above, would:

• Check that the mana it had been given hadn't dropped to 0 (in this case our scroll wants 200 mana given to it) and loop over what is required until all the mana is used up.

• Check to see if we have reached our primary time (time=3 for our case so for the first three seconds we move on).

• Moving on we get to the secondary timing (0 in our case so we enter the if statement)

• Now we check if we have enough mana (ie mana_level is higher than the manaCost of the effect)
• If we have enough we enter this second if statement and apply the effect to our object and remove the required amount of mana to perform this effect.

We loop through with time increasing by a second as we go and each effect running for only as long as the mana we've provided can manage.

No idea if this is what you're looking for but I enjoyed myself writing it anyway - hope it helps though.

In order to discourage munchkin behavior, you're going to need to balance costs with combinations. If you don't, you're going to get some rather creative combinations of seemingly small effects to pack a punch that's going to cost relatively little. At the same time, the more powerful combos will be rarely used and put a damper on game play.

you want to use a formula that increases at a multiplicative level with a base cost, the greater to be used.

so, to write some pseudo-code for you....

combo cost minimums would be....

X, X + A, X + B, X + C......

then the costs could be computed....

E = effect

Val = E1(cost) * E2(Cost) if val < x val = x

and so on.

So, you could make a base cost of a single effect, the cost of the effect.

For argument's sake, lets say Heat has a cost of 2 and cold has a cost of two, and by multiplying their costs, you get four, but you set a base cost of 6, so the combo costs six, where light with a cost of 3 and heat with a cost of three would ALSO be six. Light with a cost of three and dark with a cost of three would be nine, not affected by the minimum.

You can tweak the formula from there.

• Very helpful and definitely a good way to work out costs. Thanks! I am still trying to get a handle on the total scope of the language; which operators I should have in order to have a reasonably flexible language system. – JBiggs Feb 8 '17 at 19:31
• @JBiggs you could also set a MAX value as well if you want to tweak it to allow for slightly more powerful combinations as well. – Richard U Feb 8 '17 at 20:19

Have you ever read the GURPS Magic sourcebook? It contains a verbal language for magic that basically requires each spell to contain a Noun and a Verb like as a spell, with skill points in the nouns you know and the verbs you know. It provides a couple of examples, but it's listed as an optional rule, so it only gets about half a page of text in the rule book, if memory serves.

But that framework may work better than having a list of all possible spells. Set up a simple grammar and then let the players pick their Mad Libs style spell lists.

So a spell has, perhaps, a structure like Adjective Noun Verb.

So then the PC might have spells using that structure like:

• Flaming Arrow Shoots that is roughly equivalent to the (A)D&D Magic Missile spell.
• Warm Hand Heals is a simple touch-based healing spell.
• White Lightning Blasts fires a bolt of lightning at a target.
• Glowing Light Strengthens might cause a sword to be stronger (and glow).

and so on.

But I would focus on the rules of the grammar rather than a predefined list of all possible words/spells. This lets your players have more creativity, and also makes magic itself more unique.

• That is a great option for a pen and paper RPG, but this is not actually going to be used for a PnP RPG game. I need everything to be defined in advance, even knowing that it is going to be a large, cumbersome, and highly detailed system. – JBiggs Feb 8 '17 at 16:31
• since it's for a game I think doing it like you suggested will make it considerably harder to code. – rschpdr Feb 8 '17 at 16:32