From ab431cdfab6e1842ff357c7f380cc74142601912 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Fri, 1 Dec 2006 16:54:19 +0000 Subject: Monster sound effect patch --- src/monster.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/monster.cpp') 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; + } +} -- cgit v1.2.3-60-g2f50