From 88df3eb6e82e1a23f379416652ac4f12f22a063c Mon Sep 17 00:00:00 2001 From: Andrei Karas <akaras@inbox.ru> Date: Sun, 23 Sep 2012 14:53:21 +0300 Subject: Add to monsters.xml and npcs.xml sort offset parameters. sortOffsetY - this value will be substracted from y position while sorting deadSortOffsetY - this value will be substracted from dead bein y position while sorting By default sortOffsetY = 0 and deadSortOffsetY = 31 --- src/being.cpp | 8 ++++++-- src/resources/beinginfo.cpp | 4 +++- src/resources/beinginfo.h | 14 ++++++++++++++ src/resources/monsterdb.cpp | 6 ++++++ src/resources/npcdb.cpp | 7 +++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/being.cpp b/src/being.cpp index 465ee42dd..b08e95e96 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -307,13 +307,17 @@ void Being::setSubtype(const uint16_t subtype) { setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay()); + mYDiff = mInfo->getSortOffsetY(); } } else if (mType == NPC) { mInfo = NPCDB::get(mSubType); if (mInfo) + { setupSpriteDisplay(mInfo->getDisplay(), false); + mYDiff = mInfo->getSortOffsetY(); + } } else if (mType == PLAYER) { @@ -1058,8 +1062,8 @@ void Being::setAction(const Action &action, const int attackType A_UNUSED) currentAction = SpriteAction::DEAD; if (mInfo) sound.playSfx(mInfo->getSound(SOUND_EVENT_DIE), mX, mY); - if (mType == MONSTER) - mYDiff = 31; + if (mType == MONSTER || mType == NPC) + mYDiff = mInfo->getDeadSortOffsetY(); break; case STAND: currentAction = SpriteAction::STAND; diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 1559f594c..5ffdb887d 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -43,7 +43,9 @@ BeingInfo::BeingInfo() : mTargetOffsetY(0), mMaxHP(0), mStaticMaxHP(false), - mTargetSelection(true) + mTargetSelection(true), + mSortOffsetY(0), + mDeadSortOffsetY(31) { SpriteDisplay display; display.sprites.push_back(SpriteReference::Empty); diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 2d5971f91..8b25b4564 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -151,6 +151,18 @@ class BeingInfo bool isTargetSelection() const { return mTargetSelection; } + int getSortOffsetY() + { return mSortOffsetY; } + + void setSortOffsetY(const int n) + { mSortOffsetY = n; } + + int getDeadSortOffsetY() + { return mDeadSortOffsetY; } + + void setDeadSortOffsetY(const int n) + { mDeadSortOffsetY = n; } + static void clear(); private: @@ -166,6 +178,8 @@ class BeingInfo int mMaxHP; bool mStaticMaxHP; bool mTargetSelection; + int mSortOffsetY; + int mDeadSortOffsetY; }; typedef std::map<int, BeingInfo*> BeingInfos; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 26c72ed2f..f4987afb0 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -95,6 +95,12 @@ void MonsterDB::load() currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0)); + currentInfo->setSortOffsetY(XML::getProperty( + monsterNode, "sortOffsetY", 0)); + + currentInfo->setDeadSortOffsetY(XML::getProperty( + monsterNode, "deadSortOffsetY", 31)); + unsigned char block = 0; std::string walkStr = XML::getProperty( monsterNode, "walkType", "walk"); diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 3ce300138..81a89b611 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -85,6 +85,13 @@ void NPCDB::load() currentInfo->setTargetOffsetY(XML::getProperty(npcNode, "targetOffsetY", 0)); + + currentInfo->setSortOffsetY(XML::getProperty(npcNode, + "sortOffsetY", 0)); + + currentInfo->setDeadSortOffsetY(XML::getProperty(npcNode, + "deadSortOffsetY", 31)); + SpriteDisplay display; for_each_xml_child_node(spriteNode, npcNode) { -- cgit v1.2.3-70-g09d2