Sign in to follow this  
Darobat

Spell System

Recommended Posts

Darobat    100
Greetings How should I implement the spell/skill system in my game? There's going to be quite a number of spells, so I'm not sure of the best way to manage all of them and their info. Right now, each character has a list of the spell names he knows. When I cast it, should it go to a lookup table and then return a reference to a struct containing the spells information? Is there a better way to do it? Thanks.

Share this post


Link to post
Share on other sites
Zahlman    1682
Make the spells represented by objects, and give players a list of *spells* they know, rather than just names of spells.

A 'spell' encapsulates its name and the information about what happens when you cast it (i.e. it might have a method .invoke(Entity target), or something). You might find it useful to give the player several instances of a spell (to represent the number of times they can cast it); but you want to try to design things so that any given instance of the same spell, has the same data (internal state).

That in turn will allow you to use a Flyweight pattern of some sort. (You could for example make an object hierarchy for all Spell classes, and take a templated Singleton approach - I really don't like that way of doing things, but it's an option.)

Share this post


Link to post
Share on other sites
you might want to look into particle effects, and scripting for this. you could use Lua and your particle engine to have spell scripts. then, when you want to fire a spell, just call Load_Script(some_spell.lua).... this is what im planning and i cant see it being any slicker =).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this