Spell casting system ! Any ideas?

I’m making a game in Unity3d (c#) and I’m struggling to come up with a really great way to handle spell casting. It needs to essentially be flexible enough to handle anything you would see in a game like “league of legends”. I’m not making a moba but my ability system is designed similarly.

They way I’m doing it now - I have an ability base class (abstract) and have children like Ability_aoe, Ability_thrown, etc. However, even doing with this I run into issues where the abilities I design are so specific that making a generic system to handle something that it does seems overblown. The one thing I do like about my system is that abilities have an array of AbilityEffects. This works out quite nicely, as the abilty decides how/where the effect is applied, and the effect determines what actually happens.

I want to avoid redundancy (I’m an academic type), and place commonalities in base classes, etc. However, I’m starting to think that I should practically hard code each ability, since most of them are unique and I’ve only designed about ten characters , each with four/five abilties. But I know this is horrible as far as maintainability goes.

How have you implemented spell systems? Is there a good clean way of doing this?

Hi,
i struggled for months looking for the same thing. In the end i decided to use my own thing, and it works well so far.
I use an abstract Spell Base class with
abstract ID {get;} and a few others like Range CastTime and so on
public Cast()
public Setup(Entity Caster, Entity target),
public Spellstate state;
Private abstract Precast(),
Private abstract WhileCasting(),
Private abstract EndCast() and
Private Cleanup()

Cast() has a switch in it for a simple state system where, if i inherit it for a concrete spell, just have to set the state variable accordingly to switch to the next state. The Spell is held in constant updates by Cast() if cast by a player.
Setup() sets the spell internal variables which may be needed by the spell. For my game each player, npc or item is also inherited from a base class (Entity) with functions that such a spell can use.
In Precast() i let the player use the target circle and when confirmed switch the state variable to whilecasting, in WhileCasting() the spell performs whatever it was intended to. after it has finished it sets the state variable to endcast, EndCast() then performs things like hideCastBar() or other stuff if needed. After that state is set to cleanup which removes all temporary objects created like the targetcircle, and sets the players currently casted spell to null again.

I bet it’s not easy to exactly understand what i mean. Sorry for that (it’s early in the morning here). But maybe this can give you some ideas.

I would stick to Unity additive design pattern rather than inheritance.

Start with a base spell component that can hold any number of “effects” components under it. The spell component controls each of its effects component by common interfaces (IInvoke, IRelease, etc).
Each one of these effects implements a behavior on game world. For instance the spell “Berserk” could have the “Double damage” positive effect along with the negative “Half armor” effect. But the very same “Half armor” effect could be reused in the “Damnation” spell, and so on.

With smart use and combination of interfaces, this system can support many levels of abstraction that results in much broader results on effects. For example, the effect “Cure” could be cast on a person to cure wounds or on a building to fix damage, provided that both supports the “IStructure” interface with a “Fix()” method that is used by the cure effect.