From 62879acf891f1939e16fa32d2426b56f08f1609b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 31 Dec 2013 15:41:34 +0300 Subject: add pet direction type if owner dead. New pet db attribute: deadDirectionType --- src/being/being.cpp | 21 +++++++++++++++++++-- src/resources/beinginfo.cpp | 1 + src/resources/beinginfo.h | 7 +++++++ src/resources/db/petdb.cpp | 2 ++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/being/being.cpp b/src/being/being.cpp index d87eb5da6..160b5f925 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1714,8 +1714,25 @@ void Being::petLogic() } if (mAction == STAND) { - const int directionType = mOwner->getCurrentAction() != SIT - ? mInfo->getDirectionType() : mInfo->getSitDirectionType(); + int directionType = 0; + switch (mOwner->getCurrentAction()) + { + case STAND: + case MOVE: + case ATTACK: + case HURT: + case SPAWN: + default: + directionType = mInfo->getDirectionType(); + break; + case SIT: + directionType = mInfo->getSitDirectionType(); + break; + case DEAD: + directionType = mInfo->getDeadDirectionType(); + break; + } + int newDir = 0; switch (directionType) { diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 5193ae4d3..796c583f6 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -73,6 +73,7 @@ BeingInfo::BeingInfo() : mThinkTime(50), mDirectionType(1), mSitDirectionType(1), + mDeadDirectionType(1), mStaticMaxHP(false), mTargetSelection(true) { diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index f59dbe4d1..894920c10 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -302,6 +302,12 @@ class BeingInfo final int getSitDirectionType() const A_WARN_UNUSED { return mSitDirectionType; } + void setDeadDirectionType(const int n) + { mDeadDirectionType = n; } + + int getDeadDirectionType() const A_WARN_UNUSED + { return mDeadDirectionType; } + void setColorsList(const std::string &name); std::string getColor(const int idx) const A_WARN_UNUSED; @@ -345,6 +351,7 @@ class BeingInfo final int mThinkTime; int mDirectionType; int mSitDirectionType; + int mDeadDirectionType; bool mStaticMaxHP; bool mTargetSelection; }; diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp index cb8208179..0e81203ff 100644 --- a/src/resources/db/petdb.cpp +++ b/src/resources/db/petdb.cpp @@ -121,6 +121,8 @@ void PETDB::load() "directionType", 1)); currentInfo->setSitDirectionType(XML::getProperty(petNode, "sitDirectionType", 1)); + currentInfo->setDeadDirectionType(XML::getProperty(petNode, + "deadDirectionType", 1)); SpriteDisplay display; for_each_xml_child_node(spriteNode, petNode) -- cgit v1.2.3-60-g2f50