+
+void Monster::SubtractHealth(int amount) {
+ if (amount > Health()) {
+ health = 0;
+ } else {
+ health -= amount;
+ }
+}
+
+
+void Monster::CreateTypeDescription() {
+ Monster m;
+
+ TypeDescription &td(TypeDescription::Create(TYPE_ID, "Monster"));
+ td.SetDescription("All data of a monster.");
+ td.SetConstructor(&Construct);
+ td.SetSize(sizeof(Monster));
+
+ td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), Interpreter::STRING_ID).SetReferenced());
+ td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), Interpreter::NUMBER_ID));
+
+ td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), Interpreter::NUMBER_ID));
+ td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), Interpreter::NUMBER_ID));
+ td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), Interpreter::NUMBER_ID));
+ td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), Interpreter::NUMBER_ID));
+ td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), Stats::TYPE_ID));
+
+ td.AddField("expReward", FieldDescription(((char *)&m.expReward) - ((char *)&m), Interpreter::NUMBER_ID));
+ td.AddField("goldReward", FieldDescription(((char *)&m.goldReward) - ((char *)&m), Interpreter::NUMBER_ID));
+
+ td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
+ td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
+ td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), Animation::TYPE_ID).SetReferenced());
+}
+
+void Monster::Construct(void *data) {
+ new (data) Monster;
+}
+