summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-23 14:53:21 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-23 14:53:21 +0300
commit88df3eb6e82e1a23f379416652ac4f12f22a063c (patch)
tree130c1abe6ae6c4461910b244f6c322ede5f41466 /src
parent48f2996ccc789d740edc4b425a3e00f378a9095a (diff)
downloadplus-88df3eb6e82e1a23f379416652ac4f12f22a063c.tar.gz
plus-88df3eb6e82e1a23f379416652ac4f12f22a063c.tar.bz2
plus-88df3eb6e82e1a23f379416652ac4f12f22a063c.tar.xz
plus-88df3eb6e82e1a23f379416652ac4f12f22a063c.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp8
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/beinginfo.h14
-rw-r--r--src/resources/monsterdb.cpp6
-rw-r--r--src/resources/npcdb.cpp7
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)
{