Author Topic: A piece-wise Magic System  (Read 18914 times)

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
A piece-wise Magic System
« on: March 28, 2014, 12:31:56 AM »
this is a spell system I have been thinking about for at least 1 year, now.

the intent of this magic system is to make rapid-development of new magic spells easy. It also includes the bonus of providing the option to introduce piece-wise magic to the player and allow them to create their own magic spells within their game.

this system would work like so:
all spells are made up of parts, and the order of the parts dictate how the spell effects occur.
<damage> - this would be something like do 2 fire damage
<influence area>
     -default is your current position
other areas:
     -spot touching me
     -single spot
     -line terminating in spot (with bounce on walls or not)
     -arc on a circle at radius r
     -all cardinal or diagonal lines out to distance n.
     -closest non-selected enemy within distance n
<effect>
     -something like apply a modifier to the entities this spell affects (like teleport, haste, heal... etc.)
     -can apply effects to the ground it lands on, as well (e.g. slow monsters that touch here within the next n turns)

then I can chain items together to create different spells
<influence:line terminating in spot, no bounce> <damage:2d5 fire damage> <effect:burned for 5 turns>
<influence:line terminating in spot, no bounce> <effect:teleport to random location>

that way I can easily just create new parts of spell effects, then they can be put together in interesting ways.
for example, the self teleport spell would be very simple:
<effect:teleport>

but I could also make a teleport enemies around me spell
<influence:arc of 2PI at 1 distance><teleport>

the cost of a spell would be based upon the parts that make it up.
teleport by itself might cost merely 3mp, but adding an arc influence at distance 1 is a 20mp increase.

or I could just do that each individual piece 1, 2, 3, 4 costs a multiplier more than that which was before it. So if I wanted to deal fire damage to someone next to me, I could create a spell like:
<influence:spot touching me><fire damage><fire damage><fire damage>

then when I learn a higher level fire damage spell, I could substitute that out:
<influence:spot touching me><fire damage 2><fire damage 2><fire damage 2>

I might even be able to let the player learn different parts, then construct and save their favorite spells. This system could prove very powerful. As you can learn how to summon fire, then learn separately how to throw magic, and now you can make a fireball spell. I also think that is a lot closer to how it would work to learn new spells. Learn the pieces, put them together.

the game could still come with pre-packaged spells. It is inevitable that some sorcerers would get so advanced at creating spells that they find shortcuts to put pieces of spells together.

the more you use a specific part of a spell... e.g. fling magic in a line... the better you would get at that part... that can make things like your distance to fling, time cost, mana cost all improve.

One could also make the game even generate random spells when a new game is made!

I might also make casting time dependent upon the sum of all parts of the spell's time costs.

I think the system wouldn't be too complicated to implement, either.

I'm working on implementing this system in my jsZombie game. Which, consequently, will be greatly changed in terms of content. I'll keep everyone updated!

Anyways... back to developing!
« Last Edit: March 28, 2014, 12:35:50 AM by sokol815 »

reaver

  • Rogueliker
  • ***
  • Posts: 207
  • Karma: +0/-0
    • View Profile
Re: A piece-wise Magic System
« Reply #1 on: March 28, 2014, 08:58:35 AM »
Reminds me of the Morrowind spell generator, which was quite fun :)
Sounds like a very reasonable way to prototype stuff, but if you allow your users to make stuff, be prepared for people to discover OP combinations of effects really quickly.

rust

  • Rogueliker
  • ***
  • Posts: 70
  • Karma: +0/-0
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #2 on: March 28, 2014, 11:55:55 AM »
Not sure if you're aware of that, but in this year's 7DRL Challenge there was a game utilizing such a magic system. It's called Guilder. It has no pre-made spell combinations though.

Endorya

  • Rogueliker
  • ***
  • Posts: 513
  • Karma: +0/-0
  • The non-purist roguelike lover
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #3 on: March 28, 2014, 01:04:59 PM »
This reminds me of my old spell crafting method I had in my previous project. I abandoned it because I was harder to balance, maintain and implement due to its high flexibility. I decided instead to have base pre-made spells with a modifiable output criteria.

Nonetheless, the path your going on is a very interesting one. I really hope you succeed implementing it.
"You are never alone. Death is always near watching you."

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #4 on: March 28, 2014, 02:35:26 PM »
Success! Implemented the system last night.

It's up and running on zombiejs.

I do have some things in mind to address spell power... I am going to add a cap on max mana cost a player can spend on a spell based on the amount of mysticism a player has. I am also going to make it so effects have a mana cost associated with them, and a multiplier on the total cost of a spell. I think that has a good chance of preventing game breaking combos.
 I'll have to check out guilder.

mushroom patch

  • Rogueliker
  • ***
  • Posts: 554
  • Karma: +0/-0
    • View Profile
Re: A piece-wise Magic System
« Reply #5 on: March 28, 2014, 02:40:04 PM »
The concept would be a winner if in addition to mixing and matching effects, you had a well calibrated method of determining an appropriate cost in in-game resources for using these custom spells. Tomenet has a primitive version of what you're talking about in its "rune master" (crafter?) class. Their approach to balancing it is to make the class complete trash with huge mana costs for all useful spells and no way to increase the character's mana resources but pounding mana potions constantly. Obviously, that's not the way to go.

Another point worth considering is that allowing the player to invent combinations in combat may lead to unavoidable balance issues. For example, it's common for monsters to be given resistances to certain kinds of magic/elemental attacks/whatever as a way of controlling the challenge they pose to the player. The choice of resistances tends to be calibrated to the difficulty of obtaining the kinds of magic/attacks that are resisted. If you can cook up essentially any kind of attack whenever you want (perhaps after some process of discovery and advancement, of course), it's going to be problematic coming up with monsters that have interesting combinations of resistances -- you'll be forced to make the big ones resist everything. One solution is to force the player to decide in advance upon a relatively small collection of custom spells to use.

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #6 on: March 29, 2014, 03:48:27 PM »
Once again, wall of text. I have a lot to talk about.

TL-DR:
  • Spells will require use/reading spellbooks to keep up your skill on them.
  • Mysticism caps the total amount of mana that can be spent on a single spell cast
  • Longer spells have a cost-multiplier effect and a linear increase in time to cast; this can add up quickly (See examples at the bottom)


The concept would be a winner if in addition to mixing and matching effects, you had a well calibrated method of determining an appropriate cost in in-game resources for using these custom spells. Tomenet has a primitive version of what you're talking about in its "rune master" (crafter?) class. Their approach to balancing it is to make the class complete trash with huge mana costs for all useful spells and no way to increase the character's mana resources but pounding mana potions constantly. Obviously, that's not the way to go.

This does not seem like a mechanism I want to introduce. Basically, there are 2 types of spells in the world. Pre-made spells found in spell books and on scrolls, and player-made spells, created when a player decides they need a new spell.

Player made spells will be created outside of combat. The PC must prepare a spell and write it down in a spell book. This is a time-consuming activity... probably something that takes x amount of time, but decreases as the PC's intelligence increases, down to a minimum amount of time. The PC will then have this spell at their disposal.

I do want to require the PC to re-read spells in the spellbook to keep their skill up on it. I may be able to do that by saying over-time, you begin to forget the spell, so your chances of casting it correctly begin to deteriorate. Reading the spell in the spellbook will restore a percentage of your chance to cast it based on the mana cost of the spell and the PC's intelligence. I can also give a boost to chance to cast a spell correctly when it is used... thus the spells you use often remain castable, because you remain current on their info. I could say reading the spellbook has a 20x greater increase in casting chance vs. simply casting the spell, making reading a decent option.

Reading player-made spells works a bit differently from already existing spells. Player spells have all been constructed in similar ways. Spells that you find in the world have adaptations and shortcuts from hundreds of years of use which make them easier/more effective to cast. Thus, reading a player-made spell actually gives the chance increase in casting ability to the components the spell is based on. Thus, reading/casting a spell which includes components used in other spells will increase all related spells chance to cast in the associated areas.

Another point worth considering is that allowing the player to invent combinations in combat may lead to unavoidable balance issues. For example, it's common for monsters to be given resistances to certain kinds of magic/elemental attacks/whatever as a way of controlling the challenge they pose to the player. The choice of resistances tends to be calibrated to the difficulty of obtaining the kinds of magic/attacks that are resisted. If you can cook up essentially any kind of attack whenever you want (perhaps after some process of discovery and advancement, of course), it's going to be problematic coming up with monsters that have interesting combinations of resistances -- you'll be forced to make the big ones resist everything. One solution is to force the player to decide in advance upon a relatively small collection of custom spells to use.

I agree, making the PC over powered takes the fun out of the game unless it is incredibly difficult to reach the OP stage. One option I have thought of is that spells will never be able to deal physical damage.

A PC's mysticism limits the amount of mana they can draw from their mana reserves for any 1 spell. In order to cast high power spells, the PCs mysticism must be high itself.



Another possibility is making the total number of parts in a spell have a multiplier effect on the total cost of the spell. Each part already has an associated mana cost.

E.g.
"Touch" - makes your range yourself and anyone next to you. Costs a default of 1 mana & multiplier of 1.0
"Nova" - makes your range all enemies whose square touches yours. Costs a default of 5 mana & multiplier of 1.6
"Fire1" - deals 2d(intelligence) fire damage. costs 2 mana & multiplier of 1.3

so, making a "Touch - Fire1" vs "Touch - Fire1 - Fire1" (lots of fire damage) spell costs:
"Touch - Fire1" = (1 + 2) * (1.0 * 1.3) = 3.9 -> FLOOR -> 3
"Touch - Fire1 - Fire1"  = (1 + 2 + 2) * (1.0 * 1.3 * 1.3) = 5 * (1.69) = 8.45 -> FLOOR -> 8

Making a "Nova - Fire1"  vs "Nova - Fire1 - Fire1" spell costs:
"Nova - Fire1" =  (5 + 2) * (1.6 * 1.3) = 7 * 2.08 = 14.16 -> FLOOR -> 14
"Nova - Fire1 - Fire1" = (5 + 2 + 2) * (1.6 * 1.3 * 1.3) = 9 * 2.704 = 24.336 -> FLOOR -> 24

lets say that Fire1, Cold1, Poison1, Divine1, and Arcane1 cost the same 2 mana & 1.3 multiplier (careful combining divine and arcane damage... undead are healed by arcane damage, holy are healed by Divine damage)

if I wanted to make a rainbow damage touch spell and a rainbow damage Nova spell (geared towards not attacking holy enemies):
"Touch - Fire1 - Cold1 - Poison1 - Divine1" = (1 + 2 + 2 + 2 +2) * (1.0 * 1.3 * 1.3 * 1.3 * 1.3) = 9 * 2.8561 = 25.7 -> FLOOR -> 25. Total damage output is 1n
"Nova - Fire1 - Cold1 - Poison1 - Divine1" = (5 + 2 + 2 + 2 +2) * (1.6 * 1.3 * 1.3 * 1.3 * 1.3) = 13 * 4.56976 = 59.406 -> FLOOR -> 59. Potential damage output (if surrounded) of 8n

Be careful about the number of pieces you are combining. Each piece makes the spell drastically more expensive, and linearly increases the casting time, as each piece has it's own amount of casting time. The Rainbow Nova spell probably costs about 2.5 turns of recovery time after being cast.
« Last Edit: March 29, 2014, 04:02:45 PM by sokol815 »

Zireael

  • Rogueliker
  • ***
  • Posts: 604
  • Karma: +0/-0
    • View Profile
Re: A piece-wise Magic System
« Reply #7 on: March 30, 2014, 10:36:05 AM »
Not sure if you're aware of that, but in this year's 7DRL Challenge there was a game utilizing such a magic system. It's called Guilder. It has no pre-made spell combinations though.

I think Crimson Shit ran on something similar, too.

As for the idea - I love it! Not something for my game, but doesn't stop me appreciating it!

guest509

  • Guest
Re: A piece-wise Magic System
« Reply #8 on: March 30, 2014, 12:04:04 PM »
This general idea is how city of heroes and champions online creates their super powers. You can't really build your own powers online but in the paper RPG you can.

Morcrist

  • Newcomer
  • Posts: 9
  • Karma: +0/-0
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #9 on: March 31, 2014, 01:04:18 AM »
Reminds me of a discussion back in 2011 over on GameDev.net.

My post was here.

So many cool possibilities by combining a relatively few modifiers. Allowing mana to be dumped into each modifier provides both flexibility and limits overpowered spells because low level casters have little mana to work with (assumedly).

Interesting discussion!

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #10 on: March 31, 2014, 02:33:42 AM »
Reminds me of a discussion back in 2011 over on GameDev.net.

My post was here.

So many cool possibilities by combining a relatively few modifiers. Allowing mana to be dumped into each modifier provides both flexibility and limits overpowered spells because low level casters have little mana to work with (assumedly).

Interesting discussion!

That was a good read! I actually hadn't seen that thread on gamedev. There may have been a similar thread on here a few years ago, but I couldn't find it in a cursory search.

I am now to the point where I can actually think about implementing the user-interface to create this sort of magic. The back-end already does it, now it is just time to unleash the PC and see what people can come up with.

implementation order:
-make spellbooks with casting pieces
-allow reading of spells/scrolls
-casting/reading spells increases successful chance percentage (but not scrolls... they have the magic embedded in them!)
-UI for player spell creation.

mushroom patch

  • Rogueliker
  • ***
  • Posts: 554
  • Karma: +0/-0
    • View Profile
Re: A piece-wise Magic System
« Reply #11 on: March 31, 2014, 02:40:14 AM »
Quote
A PC's mysticism limits the amount of mana they can draw from their mana reserves for any 1 spell. In order to cast high power spells, the PCs mysticism must be high itself.

Another possibility is making the total number of parts in a spell have a multiplier effect on the total cost of the spell. Each part already has an associated mana cost.

...

Be careful about the number of pieces you are combining. Each piece makes the spell drastically more expensive, and linearly increases the casting time, as each piece has it's own amount of casting time. The Rainbow Nova spell probably costs about 2.5 turns of recovery time after being cast.

The idea of using cool downs is a good one, but I would suggest a mixture of cool downs and multipliers. My concern (if I were designing a system like this) would be less about the possibility of a the player becoming overpowered by virtue of too much raw damage (or too much of whatever the spells do for you) -- this kind of thing is relatively easy to manage -- but becoming too versatile in the range of things he can do, e.g. exploit the weaknesses of any enemy or even combination of enemies. I would suggest a context dependent multiplier that comes into play when the character switches from casting, say, spells having one elemental component to another, say from fire to ice. Something like contamination in crawl, except it has an elemental flavor and impacts casting cost multipliers (and/or failure rates, if you're into that kind of thing) of spells having opposing elemental flavors.

Of course, you could imagine variations on the concept that constrain the player's ability to suddenly switch gears in terms of the custom spells he uses.
« Last Edit: March 31, 2014, 02:43:56 AM by mushroom patch »

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #12 on: March 31, 2014, 03:48:18 AM »
The idea of using cool downs is a good one, but I would suggest a mixture of cool downs and multipliers.

That is exactly what I ended up going with.

chooseusername

  • Rogueliker
  • ***
  • Posts: 329
  • Karma: +0/-0
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #13 on: March 31, 2014, 05:18:03 AM »
Seems to me that damage is just another effect.  I worked on a game that had a virtual machine where these things were run, players couldn't create them, but game designers could without programming in the underlying language.

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: A piece-wise Magic System
« Reply #14 on: March 31, 2014, 05:53:35 AM »
Seems to me that damage is just another effect.  I worked on a game that had a virtual machine where these things were run, players couldn't create them, but game designers could without programming in the underlying language.

This is true. the only 2 differences my system sees between the two is:
1. damage has a damage attribute pointing to an array of damage to deal, the other has an effects array pointing to an array of effects to enact.
2. spells that include damage portions cannot (currently) be targeted upon the PC. (but effects like healing can. Heal Nova your enemies anyone?)