From 53cf65f40c64a0d2ea8757390179127222faa258 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Tue, 13 Mar 2012 16:18:38 +0100 Subject: Added script bind to set walkmask for beings TODO: Inform client about this change. Reviewed-by: bjorn. --- src/game-server/actor.h | 12 +++++++++--- src/game-server/character.cpp | 3 +++ src/game-server/character.h | 7 ------- src/game-server/map.h | 6 +++--- src/game-server/monster.cpp | 3 +++ src/game-server/monster.h | 9 --------- src/game-server/npc.cpp | 3 +++ src/game-server/npc.h | 6 ------ 8 files changed, 21 insertions(+), 28 deletions(-) (limited to 'src/game-server') 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 @@ -322,15 +322,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 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 -- cgit v1.2.3-70-g09d2