summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-21 03:07:34 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-21 03:07:34 +0300
commit61350cc4f65d53dd3add0c15558f6017b18ddbea (patch)
treedccde6c12fec3d5d9bfcfc25c48f7a5869b3f8ef /src
parentd2e83863e6e5faa6d6eeb3ab0c0a384dac3a0a11 (diff)
downloadmv-61350cc4f65d53dd3add0c15558f6017b18ddbea.tar.gz
mv-61350cc4f65d53dd3add0c15558f6017b18ddbea.tar.bz2
mv-61350cc4f65d53dd3add0c15558f6017b18ddbea.tar.xz
mv-61350cc4f65d53dd3add0c15558f6017b18ddbea.zip
Add monster walktype attribute to detect on what collisions monster can move.
Diffstat (limited to 'src')
-rw-r--r--src/map.h4
-rw-r--r--src/resources/beinginfo.cpp3
-rw-r--r--src/resources/mapreader.cpp3
-rw-r--r--src/resources/monsterdb.cpp25
4 files changed, 27 insertions, 8 deletions
diff --git a/src/map.h b/src/map.h
index be880f2e7..0a684140e 100644
--- a/src/map.h
+++ b/src/map.h
@@ -212,6 +212,7 @@ class Map : public Properties, public ConfigListener
BLOCKTYPE_MONSTER,
BLOCKTYPE_AIR,
BLOCKTYPE_WATER,
+ BLOCKTYPE_GROUND,
NB_BLOCKTYPES
};
@@ -230,7 +231,8 @@ class Map : public Properties, public ConfigListener
BLOCKMASK_CHARACTER = 0x01, // 0000 0001
BLOCKMASK_MONSTER = 0x02, // 0000 0010
BLOCKMASK_AIR = 0x04, // 0000 0100
- BLOCKMASK_WATER = 0x08 // 0000 1000
+ BLOCKMASK_WATER = 0x08, // 0000 1000
+ BLOCKMASK_GROUND = 0x16 // 0001 0000
};
enum DebugType
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 96cc47f94..438de46dd 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -33,7 +33,8 @@ BeingInfo::BeingInfo():
mName(_("unnamed")),
mTargetCursorSize(ActorSprite::TC_MEDIUM),
mWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER
- | Map::BLOCKMASK_MONSTER),
+ | Map::BLOCKMASK_MONSTER | Map::BLOCKMASK_AIR
+ | Map::BLOCKMASK_WATER),
mBlockType(Map::BLOCKTYPE_CHARACTER),
mTargetOffsetX(0), mTargetOffsetY(0),
mMaxHP(0), mStaticMaxHP(false)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 5bec46bdd..6d0a6fa4f 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -415,6 +415,9 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
{
switch (gid - set->getFirstGid())
{
+ case Map::COLLISION_EMPTY:
+ map->blockTile(x, y, Map::BLOCKTYPE_GROUND);
+ break;
case Map::COLLISION_WALL:
map->blockTile(x, y, Map::BLOCKTYPE_WALL);
break;
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index fbd7d10ad..ac5b2c7f9 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -82,16 +82,29 @@ void MonsterDB::load()
monsterNode, "name", _("unnamed")));
currentInfo->setTargetCursorSize(XML::getProperty(monsterNode,
- "targetCursor", "medium"));
+ "targetCursor", "medium"));
currentInfo->setTargetOffsetX(XML::getProperty(monsterNode,
- "targetOffsetX", 0));
+ "targetOffsetX", 0));
currentInfo->setTargetOffsetY(XML::getProperty(monsterNode,
- "targetOffsetY", 0));
-
- currentInfo->setMaxHP(XML::getProperty(monsterNode,
- "maxHP", 0));
+ "targetOffsetY", 0));
+
+ currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0));
+
+ unsigned char block = 0;
+ std::string walkStr = XML::getProperty(
+ monsterNode, "walkType", "walk");
+ if (walkStr == "walk")
+ block = Map::BLOCKMASK_WATER | Map::BLOCKMASK_AIR;
+ else if (walkStr == "fly")
+ block = 0;
+ else if (walkStr == "swim")
+ block = Map::BLOCKMASK_GROUND | Map::BLOCKMASK_AIR;
+ else if (walkStr == "walkswim" || walkStr == "swimwalk")
+ block = Map::BLOCKMASK_AIR;
+
+ currentInfo->setWalkMask(Map::BLOCKMASK_WALL | block);
if (currentInfo->getMaxHP())
currentInfo->setStaticMaxHP(true);