summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-04-16 09:19:56 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-09 17:39:20 +0200
commitb376d0e30fcb0c1de2aa35807419129e7dd5da17 (patch)
tree4fe3175de8d3a5acf64570f720241d1865f0d00d
parent879455af96bc36ac6a9841f385d6b538aa683939 (diff)
downloadmana-add-sound-events.tar.gz
mana-add-sound-events.tar.bz2
mana-add-sound-events.tar.xz
mana-add-sound-events.zip
Added several sound events and support for spawn animationadd-sound-events
- Added "miss" as alias for "strike" (closes #68) - Added "move", "sit" and "spawn" monster sounds
-rw-r--r--src/being.cpp8
-rw-r--r--src/being.h3
-rw-r--r--src/net/tmwa/beinghandler.cpp1
-rw-r--r--src/resources/beinginfo.h7
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/monsterdb.cpp12
-rw-r--r--src/resources/spritedef.h1
7 files changed, 30 insertions, 4 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 5e869662..c0f48871 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -583,12 +583,16 @@ void Being::setAction(Action action, int attackId)
switch (action)
{
case MOVE:
+ sound.playSfx(mInfo->getSound(SoundEvent::MOVE),
+ getPixelX(), getPixelY());
currentAction = SpriteAction::MOVE;
// Note: When adding a run action,
// Differentiate walk and run with action name,
// while using only the ACTION_MOVE.
break;
case SIT:
+ sound.playSfx(mInfo->getSound(SoundEvent::SIT),
+ getPixelX(), getPixelY());
currentAction = SpriteAction::SIT;
break;
case ATTACK:
@@ -635,6 +639,10 @@ void Being::setAction(Action action, int attackId)
case STAND:
currentAction = SpriteAction::STAND;
break;
+ case SPAWN:
+ sound.playSfx(mInfo->getSound(SoundEvent::SPAWN),
+ getPixelX(), getPixelY());
+ currentAction = SpriteAction::SPAWN;
}
if (currentAction != SpriteAction::INVALID)
diff --git a/src/being.h b/src/being.h
index b8c5a0f3..49aebd30 100644
--- a/src/being.h
+++ b/src/being.h
@@ -75,7 +75,8 @@ class Being : public ActorSprite, public EventListener
ATTACK,
SIT,
DEAD,
- HURT
+ HURT,
+ SPAWN
};
enum Speech
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 33adb93b..b680a07c 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -280,6 +280,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
break;
case SMSG_BEING_SPAWN:
+ // todo: store the spawn ID or play spawn sfx?
/*
* TODO: This packet might need handling in the future.
*/
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 2eac4237..20e66067 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -43,10 +43,13 @@ struct Attack
enum class SoundEvent
{
+ DIE,
HIT,
- MISS,
HURT,
- DIE
+ MISS,
+ MOVE,
+ SIT,
+ SPAWN,
};
/**
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index bb5b5abd..0957fd0a 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -139,7 +139,7 @@ void ItemDB::loadSoundRef(ItemInfo &itemInfo, xmlNodePtr node)
{
itemInfo.addSound(EQUIP_EVENT_HIT, filename);
}
- else if (event == "strike")
+ else if (event == "strike" || event == "miss") // #68
{
itemInfo.addSound(EQUIP_EVENT_STRIKE, filename);
}
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 38806f13..20d938be 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -112,6 +112,18 @@ void MonsterDB::readMonsterNode(xmlNodePtr node, const std::string &filename)
{
currentInfo->addSound(SoundEvent::DIE, soundFile);
}
+ else if (event == "move")
+ {
+ currentInfo->addSound(SoundEvent::MOVE, filename);
+ }
+ else if (event == "sit")
+ {
+ currentInfo->addSound(SoundEvent::SIT, filename);
+ }
+ else if (event == "spawn")
+ {
+ currentInfo->addSound(SoundEvent::SPAWN, filename);
+ }
else
{
logger->log("MonsterDB: Warning, sound effect %s for "
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index ec5e8927..3bb0b7a0 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -64,6 +64,7 @@ namespace SpriteAction
static const std::string DEAD = "dead";
static const std::string MOVE = "walk";
static const std::string ATTACK = "attack";
+ static const std::string SPAWN = "spawn";
static const std::string HURT = "hurt";
static const std::string USE_SPECIAL = "special";
static const std::string CAST_MAGIC = "magic";