From: Daniel Karbach Date: Sun, 9 Sep 2012 12:05:14 +0000 (+0200) Subject: added type description of Hero X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;ds=sidebyside;h=81da0a7970ce80843ef8f144da06c1e0e2d950a9;hp=3c176f86a79039b2bd9cc59a0c072fe37ef601cc;p=l2e.git added type description of Hero --- diff --git a/src/battle/Hero.cpp b/src/battle/Hero.cpp index 17ec08a..a736c67 100644 --- a/src/battle/Hero.cpp +++ b/src/battle/Hero.cpp @@ -12,9 +12,12 @@ #include "../common/Ikari.h" #include "../common/Item.h" #include "../common/Spell.h" +#include "../loader/TypeDescription.h" using common::Ikari; using common::Spell; +using loader::FieldDescription; +using loader::TypeDescription; using std::vector; namespace battle { @@ -150,4 +153,33 @@ void Hero::UpdateIkariMenu(const Resources *res) { } } + +void Hero::CreateTypeDescription() { + Hero h; + TypeDescription &td(TypeDescription::CreateOrGet("Hero")); + + td.SetSize(sizeof(Hero)); + + 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 *)&h.name) - ((char *)&h), stringId, true)); + td.AddField("sprite", FieldDescription(((char *)&h.sprite) - ((char *)&h), spriteId, true)); + td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId, false)); + + td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), numberId, false)); + td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), numberId, false)); + td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), numberId, false)); + td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), numberId, false)); + td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), numberId, false)); + td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), statsId, false)); + + td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), animationId, false)); + td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId, false)); + td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId, false)); +} + } diff --git a/src/battle/Hero.h b/src/battle/Hero.h index 1cce110..122ee94 100644 --- a/src/battle/Hero.h +++ b/src/battle/Hero.h @@ -130,6 +130,8 @@ public: void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; } void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; } + static void CreateTypeDescription(); + private: const char *name; graphics::Sprite *sprite; @@ -157,13 +159,13 @@ private: // TODO: vector does not seem to be a good choice std::vector spells; - Uint16 maxHealth, health; - Uint16 maxMana, mana; + int maxHealth, health; + int maxMana, mana; Stats stats; - Uint8 level; - Uint8 ip; + int level; + int ip; };