From 1026f666ae0a89cd7298d75cd55d8d1640e6c4ab Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Mon, 3 Jun 2019 23:55:08 +0200 Subject: [PATCH] Add Punch sound (work with Objects (and mobs!) and Players) --- src/game.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/game.cpp b/src/game.cpp index dd895a5c..51ee943a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -545,6 +545,12 @@ public: sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false); } + static void objectPunch(MtEvent *e, void *data) + { + SoundMaker *sm = (SoundMaker *)data; + sm->m_sound->playSound(SimpleSoundSpec("player_punch", 1.0), false); + } + static void playerDamage(MtEvent *e, void *data) { SoundMaker *sm = (SoundMaker *)data; @@ -565,6 +571,7 @@ public: mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this); mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this); mgr->reg("NodeDug", SoundMaker::nodeDug, this); + mgr->reg("ObjectPunch", SoundMaker::objectPunch, this); mgr->reg("PlayerDamage", SoundMaker::playerDamage, this); mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this); } @@ -3972,6 +3979,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed, const ItemStack & } if (do_punch_damage) { + client->event()->put(new SimpleTriggerEvent("ObjectPunch")); // Report direct punch v3f objpos = runData.selected_object->getPosition(); v3f dir = (objpos - player_position).normalize(); @@ -4749,7 +4757,7 @@ void Game::showPauseMenu() << "bgcolor[#00000060;true]" << "button_exit[3.5," << (ypos++) << ";4,0.5;btn_continue;" << strgettext("Continue") << "]"; - + #if !defined(__ANDROID__) && !defined(__IOS__) if (!simple_singleplayer_mode) { os << "button_exit[3.5," << (ypos++) << ";4,0.5;btn_change_password;"