3 #include "../common/Stats.h"
4 #include "../graphics/Animation.h"
5 #include "../graphics/Sprite.h"
6 #include "../loader/Interpreter.h"
7 #include "../loader/TypeDescription.h"
10 using graphics::Animation;
11 using graphics::Sprite;
12 using loader::FieldDescription;
13 using loader::Interpreter;
14 using loader::TypeDescription;
47 void Monster::SubtractHealth(int amount) {
48 if (amount > Health()) {
56 void Monster::CreateTypeDescription() {
59 TypeDescription &td(TypeDescription::Create(TYPE_ID, "Monster"));
60 td.SetDescription("All data of a monster.");
61 td.SetConstructor(&Construct);
62 td.SetSize(sizeof(Monster));
64 td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), Interpreter::STRING_ID).SetReferenced());
65 td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), Sprite::TYPE_ID).SetReferenced());
66 td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), Interpreter::NUMBER_ID));
68 td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), Interpreter::NUMBER_ID));
69 td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), Interpreter::NUMBER_ID));
70 td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), Interpreter::NUMBER_ID));
71 td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), Interpreter::NUMBER_ID));
72 td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), Stats::TYPE_ID));
74 td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
75 td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
76 td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
79 void Monster::Construct(void *data) {