diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-24 20:46:41 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-24 20:46:41 +0300 |
commit | b86d61e2e86f93f86c500eb578342af34d75eab1 (patch) | |
tree | 05bb3be097bfeda0177cf373acb3a9b44d7563e0 /src/resources | |
parent | f45bd8e9a3274bcdafff7f5704af275c31638607 (diff) | |
download | plus-b86d61e2e86f93f86c500eb578342af34d75eab1.tar.gz plus-b86d61e2e86f93f86c500eb578342af34d75eab1.tar.bz2 plus-b86d61e2e86f93f86c500eb578342af34d75eab1.tar.xz plus-b86d61e2e86f93f86c500eb578342af34d75eab1.zip |
Move ai attributes reading into BeingCommon.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/beingcommon.cpp | 44 | ||||
-rw-r--r-- | src/resources/beingcommon.h | 3 | ||||
-rw-r--r-- | src/resources/db/homunculusdb.cpp | 42 | ||||
-rw-r--r-- | src/resources/db/mercenarydb.cpp | 41 |
4 files changed, 50 insertions, 80 deletions
diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp index 2b63063f8..801759571 100644 --- a/src/resources/beingcommon.cpp +++ b/src/resources/beingcommon.cpp @@ -89,6 +89,50 @@ void BeingCommon::readWalkingAttributes(BeingInfo *const info, info->setBlockWalkMask(CAST_U8(block ^ allFlags)); } +void BeingCommon::readAiAttributes(BeingInfo *const info, + XmlNodePtrConst node) +{ + info->setStartFollowDist(XML::getProperty(node, + "startFollowDistance", 3)); + info->setFollowDist(XML::getProperty(node, + "followDistance", 0)); + info->setWarpDist(XML::getProperty(node, + "warpDistance", 11)); + + info->setTargetOffsetX(XML::getProperty(node, + "offsetX", 0)); + info->setTargetOffsetY(XML::getProperty(node, + "offsetY", 1)); + info->setSitOffsetX(XML::getProperty(node, + "sitOffsetX", 0)); + info->setSitOffsetY(XML::getProperty(node, + "sitOffsetY", 1)); + info->setMoveOffsetX(XML::getProperty(node, + "moveOffsetX", 0)); + info->setMoveOffsetY(XML::getProperty(node, + "moveOffsetY", 1)); + info->setDeadOffsetX(XML::getProperty(node, + "deadOffsetX", 0)); + info->setDeadOffsetY(XML::getProperty(node, + "deadOffsetY", 1)); + info->setAttackOffsetX(XML::getProperty(node, + "attackOffsetX", info->getTargetOffsetX())); + info->setAttackOffsetY(XML::getProperty(node, + "attackOffsetY", info->getTargetOffsetY())); + + info->setThinkTime(XML::getProperty(node, + "thinkTime", 500) / 10); + + info->setDirectionType(XML::getProperty(node, + "directionType", 1)); + info->setSitDirectionType(XML::getProperty(node, + "sitDirectionType", 1)); + info->setDeadDirectionType(XML::getProperty(node, + "deadDirectionType", 1)); + info->setAttackDirectionType(XML::getProperty(node, + "attackDirectionType", 4)); +} + bool BeingCommon::readObjectNodes(XmlNodePtrConst &spriteNode, SpriteDisplay &display, BeingInfo *const currentInfo, diff --git a/src/resources/beingcommon.h b/src/resources/beingcommon.h index 159cc4518..92b39db4c 100644 --- a/src/resources/beingcommon.h +++ b/src/resources/beingcommon.h @@ -57,6 +57,9 @@ namespace BeingCommon XmlNodePtrConst node, const int moreBlockFlags) A_NONNULL(1); + void readAiAttributes(BeingInfo *const info, + XmlNodePtrConst node); + void getIncludeFiles(const std::string &dir, StringVect &list, const std::string &ext); diff --git a/src/resources/db/homunculusdb.cpp b/src/resources/db/homunculusdb.cpp index 26ac28591..38ce44efe 100644 --- a/src/resources/db/homunculusdb.cpp +++ b/src/resources/db/homunculusdb.cpp @@ -98,52 +98,14 @@ void HomunculusDB::loadXmlFile(const std::string &fileName, BeingCommon::readWalkingAttributes(currentInfo, homunculusNode, 0); + BeingCommon::readAiAttributes(currentInfo, + homunculusNode); currentInfo->setMaxHP(XML::getProperty(homunculusNode, "maxHP", 0)); currentInfo->setDeadSortOffsetY(XML::getProperty( homunculusNode, "deadSortOffsetY", 31)); - currentInfo->setStartFollowDist(XML::getProperty(homunculusNode, - "startFollowDistance", 3)); - currentInfo->setFollowDist(XML::getProperty(homunculusNode, - "followDistance", 0)); - currentInfo->setWarpDist(XML::getProperty(homunculusNode, - "warpDistance", 11)); - - currentInfo->setTargetOffsetX(XML::getProperty(homunculusNode, - "offsetX", 0)); - currentInfo->setTargetOffsetY(XML::getProperty(homunculusNode, - "offsetY", 1)); - currentInfo->setSitOffsetX(XML::getProperty(homunculusNode, - "sitOffsetX", 0)); - currentInfo->setSitOffsetY(XML::getProperty(homunculusNode, - "sitOffsetY", 1)); - currentInfo->setMoveOffsetX(XML::getProperty(homunculusNode, - "moveOffsetX", 0)); - currentInfo->setMoveOffsetY(XML::getProperty(homunculusNode, - "moveOffsetY", 1)); - currentInfo->setDeadOffsetX(XML::getProperty(homunculusNode, - "deadOffsetX", 0)); - currentInfo->setDeadOffsetY(XML::getProperty(homunculusNode, - "deadOffsetY", 1)); - currentInfo->setAttackOffsetX(XML::getProperty(homunculusNode, - "attackOffsetX", currentInfo->getTargetOffsetX())); - currentInfo->setAttackOffsetY(XML::getProperty(homunculusNode, - "attackOffsetY", currentInfo->getTargetOffsetY())); - - currentInfo->setThinkTime(XML::getProperty(homunculusNode, - "thinkTime", 500) / 10); - - currentInfo->setDirectionType(XML::getProperty(homunculusNode, - "directionType", 1)); - currentInfo->setSitDirectionType(XML::getProperty(homunculusNode, - "sitDirectionType", 1)); - currentInfo->setDeadDirectionType(XML::getProperty(homunculusNode, - "deadDirectionType", 1)); - currentInfo->setAttackDirectionType(XML::getProperty(homunculusNode, - "attackDirectionType", 4)); - currentInfo->setColorsList(XML::getProperty(homunculusNode, "colors", "")); diff --git a/src/resources/db/mercenarydb.cpp b/src/resources/db/mercenarydb.cpp index bb582dc92..9e7ccf511 100644 --- a/src/resources/db/mercenarydb.cpp +++ b/src/resources/db/mercenarydb.cpp @@ -97,52 +97,13 @@ void MercenaryDB::loadXmlFile(const std::string &fileName, currentInfo->setBlockType(BlockType::NONE); BeingCommon::readBasicAttributes(currentInfo, mercenaryNode, "attack"); BeingCommon::readWalkingAttributes(currentInfo, mercenaryNode, 0); + BeingCommon::readAiAttributes(currentInfo, mercenaryNode); currentInfo->setMaxHP(XML::getProperty(mercenaryNode, "maxHP", 0)); currentInfo->setDeadSortOffsetY(XML::getProperty( mercenaryNode, "deadSortOffsetY", 31)); - currentInfo->setStartFollowDist(XML::getProperty(mercenaryNode, - "startFollowDistance", 3)); - currentInfo->setFollowDist(XML::getProperty(mercenaryNode, - "followDistance", 0)); - currentInfo->setWarpDist(XML::getProperty(mercenaryNode, - "warpDistance", 11)); - - currentInfo->setTargetOffsetX(XML::getProperty(mercenaryNode, - "offsetX", 0)); - currentInfo->setTargetOffsetY(XML::getProperty(mercenaryNode, - "offsetY", 1)); - currentInfo->setSitOffsetX(XML::getProperty(mercenaryNode, - "sitOffsetX", 0)); - currentInfo->setSitOffsetY(XML::getProperty(mercenaryNode, - "sitOffsetY", 1)); - currentInfo->setMoveOffsetX(XML::getProperty(mercenaryNode, - "moveOffsetX", 0)); - currentInfo->setMoveOffsetY(XML::getProperty(mercenaryNode, - "moveOffsetY", 1)); - currentInfo->setDeadOffsetX(XML::getProperty(mercenaryNode, - "deadOffsetX", 0)); - currentInfo->setDeadOffsetY(XML::getProperty(mercenaryNode, - "deadOffsetY", 1)); - currentInfo->setAttackOffsetX(XML::getProperty(mercenaryNode, - "attackOffsetX", currentInfo->getTargetOffsetX())); - currentInfo->setAttackOffsetY(XML::getProperty(mercenaryNode, - "attackOffsetY", currentInfo->getTargetOffsetY())); - - currentInfo->setThinkTime(XML::getProperty(mercenaryNode, - "thinkTime", 500) / 10); - - currentInfo->setDirectionType(XML::getProperty(mercenaryNode, - "directionType", 1)); - currentInfo->setSitDirectionType(XML::getProperty(mercenaryNode, - "sitDirectionType", 1)); - currentInfo->setDeadDirectionType(XML::getProperty(mercenaryNode, - "deadDirectionType", 1)); - currentInfo->setAttackDirectionType(XML::getProperty(mercenaryNode, - "attackDirectionType", 4)); - currentInfo->setColorsList(XML::getProperty(mercenaryNode, "colors", "")); |