summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-11 19:59:55 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-11 19:59:55 +0000
commitfc63e88f869919a8b035a5c41db8d05626526bde (patch)
tree8f1928d082ebbffc549c712a3f406c2141f43e01 /src/being.cpp
parent7b0f0ec315e66dcbdda58ada8b09a59bc5dcf6c9 (diff)
downloadmana-client-fc63e88f869919a8b035a5c41db8d05626526bde.tar.gz
mana-client-fc63e88f869919a8b035a5c41db8d05626526bde.tar.bz2
mana-client-fc63e88f869919a8b035a5c41db8d05626526bde.tar.xz
mana-client-fc63e88f869919a8b035a5c41db8d05626526bde.zip
Merged 0.0 changes from revision 3065 to 3177 to trunk.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 33ee7e7a..e4a1e9fc 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -33,6 +33,7 @@
#include "log.h"
#include "map.h"
+#include "resources/resourcemanager.h"
#include "resources/spriteset.h"
#include "gui/gui.h"
@@ -40,12 +41,8 @@
#include "utils/dtor.h"
#include "utils/tostring.h"
-extern Spriteset *emotionset;
-
-PATH_NODE::PATH_NODE(unsigned short x, unsigned short y):
- x(x), y(y)
-{
-}
+int Being::instances = 0;
+Spriteset *Being::emotionset = NULL;
Being::Being(Uint16 id, Uint16 job, Map *map):
mJob(job),
@@ -70,6 +67,16 @@ Being::Being(Uint16 id, Uint16 job, Map *map):
mEquipmentSpriteIDs(VECTOREND_SPRITE, 0)
{
setMap(map);
+
+ if (instances == 0)
+ {
+ // Load the emotion set
+ ResourceManager *rm = ResourceManager::getInstance();
+ emotionset = rm->getSpriteset("graphics/sprites/emotions.png", 30, 32);
+ if (!emotionset) logger->error("Unable to load emotions spriteset!");
+ }
+
+ instances++;
}
Being::~Being()
@@ -77,6 +84,14 @@ Being::~Being()
std::for_each(mSprites.begin(), mSprites.end(), make_dtor(mSprites));
clearPath();
setMap(NULL);
+
+ instances--;
+
+ if (instances == 0)
+ {
+ emotionset->decRef();
+ emotionset = NULL;
+ }
}
void Being::adjustCourse(Uint16 srcX, Uint16 srcY, Uint16 dstX, Uint16 dstY)
@@ -275,13 +290,19 @@ Being::setSpeech(const std::string &text, Uint32 time)
}
void
-Being::setDamage(Sint16 amount, Uint32 time)
+Being::takeDamage(int amount)
{
mDamage = amount ? toString(amount) : "miss";
mDamageTime = 300;
}
void
+Being::handleAttack()
+{
+ setAction(Being::ATTACK);
+}
+
+void
Being::setMap(Map *map)
{
// Remove sprite from potential previous map