4 * Created on: Aug 3, 2012
10 #include "../common/Stats.h"
11 #include "../graphics/Animation.h"
12 #include "../graphics/Sprite.h"
13 #include "../loader/Interpreter.h"
14 #include "../loader/TypeDescription.h"
17 using graphics::Animation;
18 using graphics::Sprite;
19 using loader::FieldDescription;
20 using loader::Interpreter;
21 using loader::TypeDescription;
54 void Monster::SubtractHealth(int amount) {
55 if (amount > Health()) {
63 void Monster::CreateTypeDescription() {
66 TypeDescription &td(TypeDescription::Create(TYPE_ID, "Monster"));
67 td.SetDescription("All data of a monster.");
68 td.SetConstructor(&Construct);
69 td.SetSize(sizeof(Monster));
71 td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), Interpreter::STRING_ID).SetReferenced());
72 td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), Sprite::TYPE_ID).SetReferenced());
73 td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), Interpreter::NUMBER_ID));
75 td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), Interpreter::NUMBER_ID));
76 td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), Interpreter::NUMBER_ID));
77 td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), Interpreter::NUMBER_ID));
78 td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), Interpreter::NUMBER_ID));
79 td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), Stats::TYPE_ID));
81 td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
82 td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
83 td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
86 void Monster::Construct(void *data) {