]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Monster.cpp
made monsters' rewards settable by data
[l2e.git] / src / battle / Monster.cpp
index ec179e488d3b5b0e19212204f0fff08a2585d9a1..0e87e3960683bf1f3f45771c2590c5fdb9b1b856 100644 (file)
@@ -1,12 +1,19 @@
-/*
- * Monster.cpp
- *
- *  Created on: Aug 3, 2012
- *      Author: holy
- */
-
 #include "Monster.h"
 
+#include "../common/Stats.h"
+#include "../graphics/Animation.h"
+#include "../graphics/Sprite.h"
+#include "../loader/Interpreter.h"
+#include "../loader/TypeDescription.h"
+#include "../math/Vector.h"
+
+using common::Stats;
+using graphics::Animation;
+using graphics::Sprite;
+using loader::FieldDescription;
+using loader::Interpreter;
+using loader::TypeDescription;
+
 namespace battle {
 
 Monster::Monster()
@@ -16,6 +23,10 @@ Monster::Monster()
 , attackScript(0)
 , defenseScript(0)
 
+, meleeAnimation(0)
+, attackAnimation(0)
+, spellAnimation(0)
+
 , maxHealth(0)
 , health(0)
 , maxMana(0)
@@ -42,4 +53,35 @@ void Monster::SubtractHealth(int 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;
+}
+
 }