• Advertisement
Sign in to follow this  

Spell System

This topic is 4876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement