summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-13 23:39:29 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-13 23:39:29 +0300
commit4ba35c456af28479b547f2ab2c0bd02c40c292f6 (patch)
tree007ba5942a6e9a62ee64f9b85e21cc5780eceae4 /src
parent2c302cc6cb54881fbe354cc9d5a9997788f63e56 (diff)
downloadplus-4ba35c456af28479b547f2ab2c0bd02c40c292f6.tar.gz
plus-4ba35c456af28479b547f2ab2c0bd02c40c292f6.tar.bz2
plus-4ba35c456af28479b547f2ab2c0bd02c40c292f6.tar.xz
plus-4ba35c456af28479b547f2ab2c0bd02c40c292f6.zip
Add npc attribute what allow or prevent removing npc after out of sight.
New npc attribute: allowDelete
Diffstat (limited to 'src')
-rw-r--r--src/net/ea/beingrecv.cpp9
-rw-r--r--src/resources/beinginfo.cpp3
-rw-r--r--src/resources/beinginfo.h7
-rw-r--r--src/resources/db/npcdb.cpp3
4 files changed, 20 insertions, 2 deletions
diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp
index be3cc4cb9..f09979e58 100644
--- a/src/net/ea/beingrecv.cpp
+++ b/src/net/ea/beingrecv.cpp
@@ -64,6 +64,7 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg)
// A being should be removed or has died
const BeingId id = msg.readBeingId("being id");
+ const uint8_t type = msg.readUInt8("remove flag");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
{
@@ -79,7 +80,7 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg)
if (dstBeing == localPlayer->getTarget())
localPlayer->stopAttack(true);
- if (msg.readUInt8("dead flag?") == 1U)
+ if (type == 1U)
{
if (dstBeing->getCurrentAction() != BeingAction::DEAD)
{
@@ -87,6 +88,12 @@ void BeingRecv::processBeingRemove(Net::MessageIn &msg)
dstBeing->recalcSpritesOrder();
}
}
+ else if (type == 0U && dstBeing->getType() == ActorType::Npc)
+ {
+ const BeingInfo *const info = dstBeing->getInfo();
+ if (!info || info->getAllowDelete())
+ actorManager->destroy(dstBeing);
+ }
else
{
if (dstBeing->getType() == ActorType::Player)
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 1f1033e3c..5a36892d9 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -90,7 +90,8 @@ BeingInfo::BeingInfo() :
mDeadDirectionType(1),
mAttackDirectionType(1),
mStaticMaxHP(false),
- mTargetSelection(true)
+ mTargetSelection(true),
+ mAllowDelete(true)
{
SpriteDisplay display;
display.sprites.push_back(SpriteReference::Empty);
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 3429515e0..ad5f35a85 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -311,6 +311,12 @@ class BeingInfo final
int getAttackDirectionType() const A_WARN_UNUSED
{ return mAttackDirectionType; }
+ void setAllowDelete(const bool b)
+ { mAllowDelete = b; }
+
+ int getAllowDelete() const A_WARN_UNUSED
+ { return mAllowDelete; }
+
void setColorsList(const std::string &name);
std::string getColor(const ItemColor idx) const A_WARN_UNUSED;
@@ -365,6 +371,7 @@ class BeingInfo final
int mAttackDirectionType;
bool mStaticMaxHP;
bool mTargetSelection;
+ bool mAllowDelete;
};
typedef std::map<BeingTypeId, BeingInfo*> BeingInfos;
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp
index 8b47d33b4..1d2cf4899 100644
--- a/src/resources/db/npcdb.cpp
+++ b/src/resources/db/npcdb.cpp
@@ -109,6 +109,9 @@ void NPCDB::loadXmlFile(const std::string &fileName)
currentInfo->setAvatarId(fromInt(XML::getProperty(
npcNode, "avatar", 0), BeingTypeId));
+ currentInfo->setAllowDelete(XML::getBoolProperty(npcNode,
+ "allowDelete", true));
+
SpriteDisplay display;
for_each_xml_child_node(spriteNode, npcNode)
{