summaryrefslogtreecommitdiff
path: root/src/monster.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2006-12-01 16:54:19 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2006-12-01 16:54:19 +0000
commitab431cdfab6e1842ff357c7f380cc74142601912 (patch)
treec10b04d93a14cfd1cfee98db562c5b6b00d9a2b9 /src/monster.cpp
parent30aa32025d3406920330390b97001ade27e4343a (diff)
downloadmana-ab431cdfab6e1842ff357c7f380cc74142601912.tar.gz
mana-ab431cdfab6e1842ff357c7f380cc74142601912.tar.bz2
mana-ab431cdfab6e1842ff357c7f380cc74142601912.tar.xz
mana-ab431cdfab6e1842ff357c7f380cc74142601912.zip
Monster sound effect patch
Diffstat (limited to 'src/monster.cpp')
-rw-r--r--src/monster.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/monster.cpp b/src/monster.cpp
index 017c088e..f624ff07 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -25,6 +25,7 @@
#include "animatedsprite.h"
#include "game.h"
+#include "sound.h"
#include "resources/monsterdb.h"
@@ -45,7 +46,7 @@ Monster::logic()
{
mFrame = (get_elapsed_time(mWalkTime) * 4) / mWalkSpeed;
- if (mFrame >= 4 && mAction != MONSTER_DEAD)
+ if (mFrame >= 4 && mAction != DEAD)
{
nextStep();
}
@@ -60,3 +61,36 @@ Monster::getType() const
return MONSTER;
}
+void
+Monster::setAction(Uint8 action)
+{
+ SpriteAction currentAction = ACTION_INVALID;
+
+ switch (action)
+ {
+ case WALK:
+ currentAction = ACTION_WALK;
+ break;
+ case DEAD:
+ currentAction = ACTION_DEAD;
+ sound.playSfx(MonsterDB::get(mJob-1002).getSound(EVENT_DIE).c_str());
+ break;
+ case ATTACK:
+ currentAction = ACTION_ATTACK;
+ sound.playSfx(MonsterDB::get(mJob-1002).getSound(EVENT_HIT).c_str());
+ mSprites[BASE_SPRITE]->reset();
+ break;
+ case STAND:
+ currentAction = ACTION_STAND;
+ break;
+ case HURT:
+ // Not implemented yet
+ break;
+ }
+
+ if (currentAction != ACTION_INVALID)
+ {
+ mSprites[BASE_SPRITE]->play(currentAction);
+ mAction = action;
+ }
+}