Storing attack information

Started by
1 comment, last by Rag Doll 14 years, 11 months ago
I need a list of RPG spells, which I have composed of effects classes. Damage effects, healing effects, status effects, etc. How should I go about storing the information, info like a lightning spell does X + 75 damage, or that the bio spell does 20 damage and poisons? A database? A textfile? In the code itself? Edit:This is in C++
Advertisement
How about an AttackInfo class that stores the attack information and then you push it into a vector.
I think there is no need to store that info to a database/file. Although I don't know what kind of game you are writing, but I think there is no need to store these infos any longer than a single game session.

class AttackInfo {    public:        AttackInfo(std::string msg, Monster *monster, SpellEffect *effect, int dmgAmount);        std::string m_strMsg;        Monster *m_pTargetMonster;        SpellEffect *m_pUsedSpell;        int m_nDmgAmount;};..void attackMonster(Monster *pMonster, SpellEffect *pEffect, int dmgAmount) {    //returns std::vector<AttackInfo*>    getAttackInfoList()->push_back(new AttackInfo("Critical hit!", pMonster, pEffect, dmgAmount)));}


Something like this?


Regards,
zEeLi
I agree with zeeli. I see no problem with hard coding that information into the game. If you want more than one effect per spell consider using a linked list.

However only hard code the spell information if you intend to leave it alone. If you want a more dynamic approach store it in a file. Just don't forget to encrypt that! Many games do in fact store the spell data separately from the game executable this allows them to update and tweak values more efficiently.

This topic is closed to new replies.

Advertisement