summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-03-13 16:18:38 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-03-13 16:25:18 +0100
commit53cf65f40c64a0d2ea8757390179127222faa258 (patch)
treea82479f3e77df3021d2105dda604b8e5eb2a90c4 /src/game-server
parent0075aa38fbde5c3df773cca320bcba615296624c (diff)
downloadmanaserv-53cf65f40c64a0d2ea8757390179127222faa258.tar.gz
manaserv-53cf65f40c64a0d2ea8757390179127222faa258.tar.bz2
manaserv-53cf65f40c64a0d2ea8757390179127222faa258.tar.xz
manaserv-53cf65f40c64a0d2ea8757390179127222faa258.zip
Added script bind to set walkmask for beings
TODO: Inform client about this change. Reviewed-by: bjorn.
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/actor.h12
-rw-r--r--src/game-server/character.cpp3
-rw-r--r--src/game-server/character.h7
-rw-r--r--src/game-server/map.h6
-rw-r--r--src/game-server/monster.cpp3
-rw-r--r--src/game-server/monster.h9
-rw-r--r--src/game-server/npc.cpp3
-rw-r--r--src/game-server/npc.h6
8 files changed, 21 insertions, 28 deletions
diff --git a/src/game-server/actor.h b/src/game-server/actor.h
index abc1e1d0..758424aa 100644
--- a/src/game-server/actor.h
+++ b/src/game-server/actor.h
@@ -52,7 +52,8 @@ class Actor : public Thing
mMoveTime(0),
mUpdateFlags(0),
mPublicID(65535),
- mSize(0)
+ mSize(0),
+ mWalkMask(0)
{}
~Actor();
@@ -114,11 +115,14 @@ class Actor : public Thing
bool isPublicIdValid() const
{ return (mPublicID > 0 && mPublicID != 65535); }
+ void setWalkMask(unsigned char mask)
+ { mWalkMask = mask; }
+
/**
* Gets the way the actor blocks pathfinding for other actors.
*/
- virtual unsigned char getWalkMask() const
- { return 0x00; } //can walk through everything
+ unsigned char getWalkMask() const
+ { return mWalkMask; }
/**
* Overridden in order to update the walkmap.
@@ -143,6 +147,8 @@ class Actor : public Thing
Point mPos; /**< Coordinates. */
unsigned char mSize; /**< Radius of bounding circle. */
+
+ unsigned char mWalkMask;
};
#endif // ACTOR_H
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index ccd629e8..031cf87c 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -34,6 +34,7 @@
#include "game-server/item.h"
#include "game-server/itemmanager.h"
#include "game-server/gamehandler.h"
+#include "game-server/map.h"
#include "game-server/mapcomposite.h"
#include "game-server/mapmanager.h"
#include "game-server/skillmanager.h"
@@ -97,6 +98,8 @@ Character::Character(MessageIn &msg):
it1_end = attr.end(); it1 != it1_end; ++it1)
mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second)));
+ setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER);
+
// Get character data.
mDatabaseID = msg.readInt32();
setName(msg.readString());
diff --git a/src/game-server/character.h b/src/game-server/character.h
index 1f82a101..f54d4ec4 100644
--- a/src/game-server/character.h
+++ b/src/game-server/character.h
@@ -372,13 +372,6 @@ class Character : public Being
Script::Thread *getNpcThread() const
{ return mNpcThread; }
-
- /**
- * Gets the way the actor is blocked by other things on the map
- */
- virtual unsigned char getWalkMask() const
- { return 0x82; } // blocked by walls and monsters ( bin 1000 0010)
-
/** Makes it impossible to chat for a while */
void mute(int seconds)
{ setTimerHard(T_C_MUTE, seconds * 10); }
diff --git a/src/game-server/map.h b/src/game-server/map.h
index 28faed7f..9f058fbf 100644
--- a/src/game-server/map.h
+++ b/src/game-server/map.h
@@ -72,7 +72,7 @@ class MapObject
{ }
void addProperty(const std::string &key, const std::string &value)
- {
+ {
if (mProperties.contains(key))
LOG_WARN("Duplicate property " << key <<
" of object " << mName);
@@ -178,7 +178,7 @@ class Map
void setProperty(const std::string &key, const std::string &val)
{ mProperties[key] = val; }
- /**
+ /**
* Adds an object.
*/
void addObject(MapObject *object)
@@ -198,7 +198,6 @@ class Map
unsigned char walkmask,
int maxCost = 20) const;
- private:
/**
* Blockmasks for different entities
*/
@@ -206,6 +205,7 @@ class Map
static const unsigned char BLOCKMASK_CHARACTER = 0x01;// = bin 0000 0001
static const unsigned char BLOCKMASK_MONSTER = 0x02; // = bin 0000 0010
+ private:
// map properties
int mWidth, mHeight;
int mTileWidth, mTileHeight;
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 1e68892d..0bee4c9a 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -26,6 +26,7 @@
#include "game-server/character.h"
#include "game-server/collisiondetection.h"
#include "game-server/item.h"
+#include "game-server/map.h"
#include "game-server/mapcomposite.h"
#include "game-server/state.h"
#include "scripting/scriptmanager.h"
@@ -55,6 +56,8 @@ Monster::Monster(MonsterClass *specy):
{
LOG_DEBUG("Monster spawned! (id: " << mSpecy->getId() << ").");
+ setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER);
+
/*
* Initialise the attribute structures.
*/
diff --git a/src/game-server/monster.h b/src/game-server/monster.h
index 5ccabfa9..0ece89ab 100644
--- a/src/game-server/monster.h
+++ b/src/game-server/monster.h
@@ -323,15 +323,6 @@ class Monster : public Being
void forgetTarget(Thing *being);
/**
- * Returns the way the actor is blocked by other things on the map.
- */
- virtual unsigned char getWalkMask() const
- {
- // blocked walls, other monsters and players ( bin 1000 0011)
- return 0x83;
- }
-
- /**
* Called when an attribute modifier is changed.
* Recalculate the base value of an attribute and update derived
* attributes if it has changed.
diff --git a/src/game-server/npc.cpp b/src/game-server/npc.cpp
index 5583c3d5..82cd6a51 100644
--- a/src/game-server/npc.cpp
+++ b/src/game-server/npc.cpp
@@ -20,6 +20,7 @@
#include "game-server/character.h"
#include "game-server/gamehandler.h"
+#include "game-server/map.h"
#include "game-server/npc.h"
#include "net/messageout.h"
#include "scripting/script.h"
@@ -30,6 +31,8 @@ NPC::NPC(const std::string &name, int id):
mID(id),
mEnabled(true)
{
+ setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER |
+ Map::BLOCKMASK_CHARACTER);
setName(name);
}
diff --git a/src/game-server/npc.h b/src/game-server/npc.h
index f62f72c7..49dd4bfa 100644
--- a/src/game-server/npc.h
+++ b/src/game-server/npc.h
@@ -82,12 +82,6 @@ class NPC : public Being
int getNPC() const
{ return mID; }
- /**
- * Gets the way an NPC is blocked by other things on the map
- */
- virtual unsigned char getWalkMask() const
- { return 0x83; } // blocked like a monster by walls, monsters and characters ( bin 1000 0011)
-
protected:
/**
* Gets the way a monster blocks pathfinding for other objects