From: Daniel Karbach Date: Wed, 29 Aug 2012 21:32:48 +0000 (+0200) Subject: interpret Monster's meleeAnimation property X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=18f74a6be69846207f4184ab8570b29e8a39f592;p=l2e.git interpret Monster's meleeAnimation property --- diff --git a/src/loader/Interpreter.cpp b/src/loader/Interpreter.cpp index 0ff8776..65db6a0 100644 --- a/src/loader/Interpreter.cpp +++ b/src/loader/Interpreter.cpp @@ -268,9 +268,10 @@ void Interpreter::ReadObject(const Definition &dfn) { ReadMonster(monsters.back(), *dfn.GetProperties()); parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, MONSTER, monsters.size() - 1))); } else if (dfn.TypeName() == "Sprite") { + int index(sprites.size()); sprites.push_back(Sprite()); ReadSprite(sprites.back(), *dfn.GetProperties()); - parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, SPRITE, sprites.size() - 1))); + parsedDefinitions.insert(make_pair(dfn.Identifier(), ParsedDefinition(&dfn, SPRITE, index))); } else { throw Error("unhandled object type: " + dfn.TypeName()); } @@ -368,6 +369,8 @@ void Interpreter::ReadMonster(Monster &m, const PropertyList &props) { m.SetStats(stats); } else if (i->first == "attackAnimation") { m.SetAttackAnimation(GetAnimation(*i->second)); + } else if (i->first == "meleeAnimation") { + m.SetMeleeAnimation(GetAnimation(*i->second)); } else { throw Error("unknown Monster property: " + i->first); } diff --git a/test-data/test.l2s b/test-data/test.l2s index 31c4ace..74e71cd 100644 --- a/test-data/test.l2s +++ b/test-data/test.l2s @@ -1,14 +1,17 @@ Number frameTime 33 Number twoFramesTime 66 -Number fiveFramesTime 165 +Number fourFramesTime 132 +Number fiveFramesTime 165 // darn, i really need to implement expressions + +Sprite lizardSprite { + // using pathes relative to project root until path resolution is implemented + image: "test-data/monster.png", + size: <64,64> +} export Monster lizard { name: "Lizard", - sprite: Sprite { - // using pathes relative to project root until path resolution is implemented - image: "test-data/monster.png", - size: <64,64> - }, + sprite: lizardSprite, level: 1, maxHealth: 8, health: 8, @@ -21,7 +24,18 @@ export Monster lizard { gut: 6, mgr: 6 }, - attackAnimation: SimpleAnimation { + attackAnimation: ComplexAnimation { + sprite: lizardSprite, + frametime: fourFramesTime, + repeat: false, + frames: [ + { column: 0, row: 1, disposition: < 0, 16> }, + { column: 0, row: 0, disposition: < 0, 16> }, + { column: 0, row: 1, disposition: < 0, 16> }, + { column: 0, row: 0, disposition: < 0, 16> } + ] + }, + meleeAnimation: SimpleAnimation { sprite: Sprite { image: "test-data/attack-monster.png", size: <96,64>