X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHero.cpp;h=d09b824d4961f5edb5fc397ec90740de8eae86dd;hb=092a2dd175a4001a495c84ee85211734fb928c83;hp=d117da078ed072bc8dfa9a00d8f70519ccc91325;hpb=8bf720f722ca1b4a95f5a5c340dad39859115de4;p=l2e.git diff --git a/src/battle/Hero.cpp b/src/battle/Hero.cpp index d117da0..d09b824 100644 --- a/src/battle/Hero.cpp +++ b/src/battle/Hero.cpp @@ -1,10 +1,3 @@ -/* - * Hero.cpp - * - * Created on: Aug 6, 2012 - * Author: holy - */ - #include "Hero.h" #include "AttackChoice.h" @@ -12,58 +5,27 @@ #include "../common/Ikari.h" #include "../common/Item.h" #include "../common/Spell.h" -#include "../loader/TypeDescription.h" +#include "../math/Vector.h" using common::Ikari; using common::Spell; -using loader::FieldDescription; -using loader::TypeDescription; using std::vector; namespace battle { Hero::Hero() -: name("") -, sprite(0) - -, weapon(0) -, armor(0) -, shield(0) -, helmet(0) -, ring(0) -, jewel(0) - -, meleeAnimation(0) -, attackAnimation(0) -, spellAnimation(0) - -, maxHealth(0) -, health(0) -, maxMana(0) -, mana(0) - -, level(0) -, ip(0) { +: master(0) { } -Hero::~Hero() { +Hero::Hero(common::Hero &h) +: master(&h) +, stats(h.GetStats()) { } +Hero::~Hero() { -void Hero::SubtractHealth(int amount) { - if (amount > Health()) { - health = 0; - } else { - health -= amount; - int ipGain(amount * 255 / health); - if (ip + ipGain > 255) { - ip = 255; - } else { - ip += ipGain; - } - } } @@ -153,33 +115,4 @@ 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, true)); - td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId, true)); - td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId, true)); -} - }