From: Daniel Karbach Date: Wed, 31 Oct 2012 21:31:38 +0000 (+0100) Subject: added hero's level ladder X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=8d14039cfc64a5da19941eba65df34347fa374d5;p=l2e.git added hero's level ladder --- diff --git a/src/common/Hero.cpp b/src/common/Hero.cpp index 373f63d..8222e12 100644 --- a/src/common/Hero.cpp +++ b/src/common/Hero.cpp @@ -33,6 +33,8 @@ Hero::Hero() , level(0) , experience(0) +, levelLadder(0) +, numLevels(0) , weapon(0) , armor(0) @@ -64,6 +66,16 @@ void Hero::SubtractHealth(int amount) { } +int Hero::NextLevel() const { + int levelOffset(Level() - 1); + if (levelOffset < numLevels) { + return levelLadder[levelOffset] - Experience(); + } else { + return 0; + } +} + + void Hero::CreateTypeDescription() { Hero h; @@ -82,6 +94,7 @@ void Hero::CreateTypeDescription() { td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), Stats::TYPE_ID)); td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), Interpreter::NUMBER_ID)); + td.AddField("ladder", FieldDescription(((char *)&h.levelLadder) - ((char *)&h), Interpreter::NUMBER_ID).SetReferenced().SetAggregate()); td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), Sprite::TYPE_ID).SetReferenced().SetDescription("the sprite used for battle scenes")); td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), Animation::TYPE_ID).SetReferenced().SetDescription("the animation played for physical attacks")); diff --git a/src/common/Hero.h b/src/common/Hero.h index 6c03eee..77269c6 100644 --- a/src/common/Hero.h +++ b/src/common/Hero.h @@ -48,6 +48,7 @@ public: Uint8 Level() const { return level; } int Experience() const { return experience; } + int NextLevel() const; Item *Weapon() { return weapon; } Item *Armor() { return armor; } @@ -107,6 +108,9 @@ private: int level; int experience; + int *levelLadder; + int numLevels; + Item *weapon; Item *armor; Item *shield; diff --git a/test-data/test.l2s b/test-data/test.l2s index 4a4bb05..1267b9f 100644 --- a/test-data/test.l2s +++ b/test-data/test.l2s @@ -88,6 +88,9 @@ export Hero maxim { gut: 100, mgr: 10 }, + ladder: [ + 10 + ], attackAnimation: ComplexAnimation { sprite: maximSprite, frametime: frameTime,