svenskmand {l Wrote}:From what I understood from oln's post and your reply to him, he wants to store basic creature stats e.g. health, mana, movespeeds, a container for attacks/spells and other stuff in the CreatureClass. And I think that is a good idea as they are common to all creatures. The name of the mesh and other stuff could also be included here.
StefanP.MUC {l Wrote}:Is CreatureClass a class for stuff that defines "Human", "Undead" and "Constructs"? If so, then I'm wonder why it has properties like meshName, sightRadius, creatureJob which are clearly properties of an individual Creature.
I have trouble following you here, why could meshName, sightRadius and creatureJob not be properties of CreatureClass (which all creatures inherits from)? It is a class not an instance/object, each instance/object get their own value here.
That's not quite what I meant.
I think creatureclass should store information about the creature class( as in in-game class), such as stat increases per level, mesh filename, job, name of the class, sound filenames etc. I.e things that are static for the type of creature, basically what is stored in the creature class definition file. Which means this will really be a pure data object. Storing this information for each creature instance is redundant. (Unless one want's to be able to alter this for each individual instance.)
Then each creature would store a reference to the creature type object (which will be in a list somewhere) which describes the type of creature it is.
Values that are meant to change after the creature is created is stored in the creature object itself.
Currently it looks like this:
- {l Code}: {l Select All Code}
class CreatureClass: public AnimatedObject
{
public:
enum CreatureJob
{
nullCreatureJob = 0,
basicWorker = 1,
advancedWorker,
scout,
weakFighter,
weakSpellcaster,
weakBuilder,
strongFighter,
strongSpellcaster,
strongBuilder,
guard,
specialCreature,
summon,
superCreature
};
// Constructors and operators
CreatureClass();
static CreatureJob creatureJobFromString(std::string s);
static std::string creatureJobToString(CreatureJob c);
bool isWorker() const{return (creatureJob == basicWorker || creatureJob == advancedWorker);}
std::string getOgreNamePrefix();
// Class properties
//NOTE: Anything added to this class must be included in the '=' operator for the Creature class.
CreatureJob creatureJob;
std::string className;
std::string meshName;
std::string bedMeshName;
int bedDim1, bedDim2;
Ogre::Vector3 scale;
double sightRadius; // The inner radius where the creature sees everything
double digRate; // Fullness removed per turn of digging
double danceRate; // How much the danced upon tile's color changes per turn of dancing
double hpPerLevel;
double manaPerLevel;
double maxHP, maxMana;
// Probability coefficients to determine how likely a creature is to come through the portal.
double coefficientHumans;
double coefficientCorpars;
double coefficientUndead;
double coefficientConstructs;
double coefficientDenizens;
double coefficientAltruism;
double coefficientOrder;
double coefficientPeace;
//std::vector<std::string> soundNames;
static std::string getFormat();
const std::string& getName() const
{
return name;
}
std::string name;
friend std::ostream& operator<<(std::ostream& os, CreatureClass *c);
friend std::istream& operator>>(std::istream& is, CreatureClass *c);
};
Besides needing some cleanup, I think the only variable here that will be changed after creature creating is scale, so it should be moved to
Creature, also a bunch of variables have to be added. It should no longer inherit from animated object, as that part is taken care of in the creature class.
(Also, since we are going to change it to load from XML, this will require some changes as well.)