]> git.localhorst.tv Git - l2e.git/commitdiff
added type description of Monster
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 9 Sep 2012 12:19:49 +0000 (14:19 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 9 Sep 2012 12:19:49 +0000 (14:19 +0200)
src/battle/Monster.cpp
src/battle/Monster.h

index f0b9f3782f0587c1d289d671b669c73c970427b7..7408eeea09939685e186f0018cfe6fcee20235a6 100644 (file)
@@ -7,6 +7,11 @@
 
 #include "Monster.h"
 
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
 namespace battle {
 
 Monster::Monster()
@@ -46,4 +51,32 @@ void Monster::SubtractHealth(int amount) {
        }
 }
 
+
+void Monster::CreateTypeDescription() {
+       Monster m;
+       TypeDescription &td(TypeDescription::CreateOrGet("Monster"));
+
+       td.SetSize(sizeof(Monster));
+
+       int animationId(TypeDescription::GetTypeId("Animation"));
+       int numberId(TypeDescription::GetTypeId("Number"));
+       int spriteId(TypeDescription::GetTypeId("Sprite"));
+       int statsId(TypeDescription::GetTypeId("Stats"));
+       int stringId(TypeDescription::GetTypeId("String"));
+
+       td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId, true));
+       td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId, true));
+       td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId, false));
+
+       td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId, false));
+       td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId, false));
+       td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId, false));
+       td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId, false));
+       td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId, false));
+
+       td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId, true));
+       td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId, true));
+       td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId, true));
+}
+
 }
index c12567257e01a33e69d45acbb0f451c18db4609e..c5c75caa1ad2d5bd83f4db0d52ed27a81a3d4555 100644 (file)
@@ -84,6 +84,8 @@ public:
        AttackChoice &GetAttackChoice() { return attackChoice; }
        const AttackChoice &GetAttackChoice() const { return attackChoice; }
 
+       static void CreateTypeDescription();
+
 private:
        const char *name;
        graphics::Sprite *sprite;