From: Daniel Karbach Date: Sun, 9 Sep 2012 12:19:49 +0000 (+0200) Subject: added type description of Monster X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=c45562467a2845a9f5b6942e8bf091251f5d16d6;p=l2e.git added type description of Monster --- diff --git a/src/battle/Monster.cpp b/src/battle/Monster.cpp index f0b9f37..7408eee 100644 --- a/src/battle/Monster.cpp +++ b/src/battle/Monster.cpp @@ -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)); +} + } diff --git a/src/battle/Monster.h b/src/battle/Monster.h index c125672..c5c75ca 100644 --- a/src/battle/Monster.h +++ b/src/battle/Monster.h @@ -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;