From 994b02f5af05158f6da3964dee5f00e6f00ae981 Mon Sep 17 00:00:00 2001 From: "luksor111@gmail.com" Date: Fri, 21 Dec 2012 18:05:34 +0000 Subject: Added sounds to levers and mobs git-svn-id: http://mc-server.googlecode.com/svn/trunk@1093 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Blocks/BlockLever.cpp | 11 ++++++++++- source/Mobs/Bat.cpp | 2 ++ source/Mobs/Blaze.cpp | 2 ++ source/Mobs/Cavespider.cpp | 2 ++ source/Mobs/Chicken.cpp | 2 ++ source/Mobs/Cow.cpp | 2 ++ source/Mobs/Creeper.cpp | 2 ++ source/Mobs/Enderman.cpp | 2 ++ source/Mobs/Ghast.cpp | 2 ++ source/Mobs/Magmacube.cpp | 2 ++ source/Mobs/Monster.cpp | 4 ++++ source/Mobs/Monster.h | 3 +++ source/Mobs/Mooshroom.cpp | 2 ++ source/Mobs/Ocelot.cpp | 2 ++ source/Mobs/Pig.cpp | 2 ++ source/Mobs/Sheep.cpp | 2 ++ source/Mobs/Silverfish.cpp | 2 ++ source/Mobs/Skeleton.cpp | 2 ++ source/Mobs/Slime.cpp | 2 ++ source/Mobs/Spider.cpp | 2 ++ source/Mobs/Wolf.cpp | 2 ++ source/Mobs/Zombie.cpp | 2 ++ source/Mobs/Zombiepigman.cpp | 2 ++ 23 files changed, 57 insertions(+), 1 deletion(-) diff --git a/source/Blocks/BlockLever.cpp b/source/Blocks/BlockLever.cpp index 925a5bdcd..cf0255df5 100644 --- a/source/Blocks/BlockLever.cpp +++ b/source/Blocks/BlockLever.cpp @@ -40,7 +40,16 @@ void cBlockLeverHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) { //Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off. - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f)); + NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f); + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta); + if(Meta & 0x08) + { + a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f); + } + else + { + a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.5f); + } } diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index e77cfd46d..952b0d899 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -10,6 +10,8 @@ cBat::cBat(void) { m_MobType = 65; + m_SoundHurt = "mob.bat.hurt"; + m_SoundDeath = "mob.bat.death"; GetMonsterConfig("Bat"); } diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp index c3a1fbabf..bab0ea13a 100644 --- a/source/Mobs/Blaze.cpp +++ b/source/Mobs/Blaze.cpp @@ -10,6 +10,8 @@ cBlaze::cBlaze(void) { m_MobType = 61; + m_SoundHurt = "mob.blaze.hit"; + m_SoundDeath = "mob.blaze.death"; GetMonsterConfig("Blaze"); } diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp index 94eadf12d..b9d4829bc 100644 --- a/source/Mobs/Cavespider.cpp +++ b/source/Mobs/Cavespider.cpp @@ -10,6 +10,8 @@ cCavespider::cCavespider(void) { m_MobType = 59; + m_SoundHurt = "mob.spider.say"; + m_SoundDeath = "mob.spider.death"; GetMonsterConfig("Cavespider"); } diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp index fe6526d76..55bf73584 100644 --- a/source/Mobs/Chicken.cpp +++ b/source/Mobs/Chicken.cpp @@ -16,6 +16,8 @@ cChicken::cChicken(void) { m_MobType = 93; + m_SoundHurt = "mob.chicken.hurt"; + m_SoundDeath = "mob.chicken.hurt"; GetMonsterConfig("Chicken"); } diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp index f6ae5b7da..b0dab1e0f 100644 --- a/source/Mobs/Cow.cpp +++ b/source/Mobs/Cow.cpp @@ -16,6 +16,8 @@ cCow::cCow(void) { m_MobType = 92; + m_SoundHurt = "mob.cow.hurt"; + m_SoundDeath = "mob.cow.hurt"; GetMonsterConfig("Cow"); } diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp index e3610198f..b3133d7c9 100644 --- a/source/Mobs/Creeper.cpp +++ b/source/Mobs/Creeper.cpp @@ -10,6 +10,8 @@ cCreeper::cCreeper(void) { m_MobType = 50; + m_SoundHurt = "mob.creeper.say"; + m_SoundDeath = "mob.creeper.say"; GetMonsterConfig("Creeper"); } diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp index 2739265f1..2814ab71b 100644 --- a/source/Mobs/Enderman.cpp +++ b/source/Mobs/Enderman.cpp @@ -10,6 +10,8 @@ cEnderman::cEnderman(void) { m_MobType = 58; + m_SoundHurt = "mob.endermen.hit"; + m_SoundDeath = "mob.endermen.death"; GetMonsterConfig("Enderman"); } diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp index 0e1656b95..38f6af582 100644 --- a/source/Mobs/Ghast.cpp +++ b/source/Mobs/Ghast.cpp @@ -10,6 +10,8 @@ cGhast::cGhast(void) { m_MobType = 56; + m_SoundHurt = "mob.ghast.scream"; + m_SoundDeath = "mob.ghast.death"; GetMonsterConfig("Ghast"); } diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index a71463928..f514d6177 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -10,6 +10,8 @@ cMagmacube::cMagmacube() { m_MobType = 62; + m_SoundHurt = "mob.magmacube.big"; + m_SoundDeath = "mob.magmacube.big"; GetMonsterConfig("Magmacube"); } diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 6c9b870e1..04989caac 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -38,6 +38,8 @@ cMonster::cMonster(void) , m_DestroyTimer( 0 ) , m_Jump(0) , m_MobType( 0 ) + , m_SoundHurt( "" ) + , m_SoundDeath( "" ) , m_EMState(IDLE) , m_SightDistance(25) , m_SeePlayerInterval (0) @@ -303,6 +305,7 @@ void cMonster::HandlePhysics(float a_Dt) void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { super::DoTakeDamage(a_TDI); + if((m_SoundHurt != "") && (m_Health > 0)) m_World->BroadcastSoundEffect(m_SoundHurt, (int)(m_Pos.x * 8), (int)(m_Pos.y * 8), (int)(m_Pos.z * 8), 1.0f, 0.8f); if (a_TDI.Attacker != NULL) { m_Target = a_TDI.Attacker; @@ -317,6 +320,7 @@ void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) void cMonster::KilledBy(cPawn * a_Killer) { super::KilledBy(a_Killer); + if(m_SoundHurt != "") m_World->BroadcastSoundEffect(m_SoundDeath, (int)(m_Pos.x * 8), (int)(m_Pos.y * 8), (int)(m_Pos.z * 8), 1.0f, 0.8f); m_DestroyTimer = 0; } diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 051477162..2c26045ff 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -92,6 +92,9 @@ protected: char m_MobType; + AString m_SoundHurt; + AString m_SoundDeath; + float m_SeePlayerInterval; float m_AttackDamage; float m_AttackRange; diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp index aca32873f..148b0c068 100644 --- a/source/Mobs/Mooshroom.cpp +++ b/source/Mobs/Mooshroom.cpp @@ -16,6 +16,8 @@ cMooshroom::cMooshroom(void) { m_MobType = 96; + m_SoundHurt = "mob.cow.hurt"; + m_SoundDeath = "mob.cow.hurt"; GetMonsterConfig("Mooshroom"); } diff --git a/source/Mobs/Ocelot.cpp b/source/Mobs/Ocelot.cpp index 02d5ccc37..df2eb5c04 100644 --- a/source/Mobs/Ocelot.cpp +++ b/source/Mobs/Ocelot.cpp @@ -10,6 +10,8 @@ cOcelot::cOcelot() { m_MobType = 98; + m_SoundHurt = "mob.cat.hitt"; + m_SoundDeath = "mob.cat.hitt"; GetMonsterConfig("Ocelot"); } diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp index 0e0d4e875..c75d0c0bf 100644 --- a/source/Mobs/Pig.cpp +++ b/source/Mobs/Pig.cpp @@ -10,6 +10,8 @@ cPig::cPig(void) { m_MobType = 90; + m_SoundHurt = "mob.pig.say"; + m_SoundDeath = "mob.pig.death"; GetMonsterConfig("Pig"); } diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp index 997184dcf..c4cdba1cf 100644 --- a/source/Mobs/Sheep.cpp +++ b/source/Mobs/Sheep.cpp @@ -13,6 +13,8 @@ cSheep::cSheep(void) : m_WoolColor(E_META_WOOL_WHITE) { m_MobType = 91; + m_SoundHurt = "mob.sheep.say"; + m_SoundDeath = "mob.sheep.say"; GetMonsterConfig("Sheep"); } diff --git a/source/Mobs/Silverfish.cpp b/source/Mobs/Silverfish.cpp index a8ced0b6b..d62b7cc14 100644 --- a/source/Mobs/Silverfish.cpp +++ b/source/Mobs/Silverfish.cpp @@ -10,6 +10,8 @@ cSilverfish::cSilverfish(void) { m_MobType = 60; + m_SoundHurt = "mob.silverfish.hit"; + m_SoundDeath = "mob.silverfish.kill"; GetMonsterConfig("Silverfish"); } diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp index 684e1e13d..279aa0fe3 100644 --- a/source/Mobs/Skeleton.cpp +++ b/source/Mobs/Skeleton.cpp @@ -10,6 +10,8 @@ cSkeleton::cSkeleton(void) { m_MobType = 51; + m_SoundHurt = "mob.skeleton.hurt"; + m_SoundDeath = "mob.skeleton.death"; GetMonsterConfig("Skeleton"); } diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp index 5df887934..c95915215 100644 --- a/source/Mobs/Slime.cpp +++ b/source/Mobs/Slime.cpp @@ -12,6 +12,8 @@ cSlime::cSlime(void) { m_MobType = 55; + m_SoundHurt = "mob.slime.attack"; + m_SoundDeath = "mob.slime.attack"; GetMonsterConfig("Slime"); } diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp index 1e1338b58..608858a5e 100644 --- a/source/Mobs/Spider.cpp +++ b/source/Mobs/Spider.cpp @@ -10,6 +10,8 @@ cSpider::cSpider() { m_MobType = 52; + m_SoundHurt = "mob.spider.say"; + m_SoundDeath = "mob.spider.death"; GetMonsterConfig("Spider"); } diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp index 5a8ceabbc..52bfb46cb 100644 --- a/source/Mobs/Wolf.cpp +++ b/source/Mobs/Wolf.cpp @@ -10,6 +10,8 @@ cWolf::cWolf(void) { m_MobType = 95; + m_SoundHurt = "mob.wolf.hurt"; + m_SoundDeath = "mob.wolf.death"; GetMonsterConfig("Wolf"); } diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp index 15e99734b..c3e331226 100644 --- a/source/Mobs/Zombie.cpp +++ b/source/Mobs/Zombie.cpp @@ -10,6 +10,8 @@ cZombie::cZombie() { m_MobType = 54; + m_SoundHurt = "mob.zombie.hurt"; + m_SoundDeath = "mob.zombie.death"; GetMonsterConfig("Zombie"); } diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index 37cf02925..89e679050 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -10,6 +10,8 @@ cZombiepigman::cZombiepigman() { m_MobType = 57; + m_SoundHurt = "mob.zombiepig.zpighurt"; + m_SoundDeath = "mob.zombiepig.zpigdeath"; GetMonsterConfig("Zombiepigman"); } -- cgit v1.2.3