Add 'silent' armor group

This commit is contained in:
stujones11 2019-06-23 20:53:31 +01:00 committed by MoNTE48
parent 79d4eab9e8
commit 36f8752700
3 changed files with 8 additions and 9 deletions

View File

@ -103,7 +103,7 @@ core.register_entity(":__builtin:item", {
else else
self.itemstring = staticdata self.itemstring = staticdata
end end
self.object:set_armor_groups({immortal = 1}) self.object:set_armor_groups({immortal = 1, silent = 1})
self.object:set_velocity({x = 0, y = 2, z = 0}) self.object:set_velocity({x = 0, y = 2, z = 0})
self.object:set_acceleration({x = 0, y = -gravity, z = 0}) self.object:set_acceleration({x = 0, y = -gravity, z = 0})
self:set_item() self:set_item()

View File

@ -43,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "camera.h" // CameraModes #include "camera.h" // CameraModes
#include "wieldmesh.h" #include "wieldmesh.h"
#include "log.h" #include "log.h"
#include "itemgroup.h"
#include <algorithm> #include <algorithm>
class Settings; class Settings;
@ -1790,6 +1791,12 @@ bool GenericCAO::directReportPunch(v3f dir, const ItemStack *punchitem,
punchitem, punchitem,
time_from_last_punch); time_from_last_punch);
if (!itemgroup_get(m_armor_groups, "silent")) {
SimpleSoundSpec spec;
spec.name = "player_punch";
spec.gain = 1.0f;
m_client->sound()->playSoundAt(spec, false, getPosition());
}
if(result.did_punch && result.damage != 0) if(result.did_punch && result.damage != 0)
{ {
if(result.damage < m_hp) if(result.damage < m_hp)

View File

@ -545,12 +545,6 @@ public:
sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false); 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) static void playerDamage(MtEvent *e, void *data)
{ {
SoundMaker *sm = (SoundMaker *)data; SoundMaker *sm = (SoundMaker *)data;
@ -571,7 +565,6 @@ public:
mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this); mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this);
mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this); mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this);
mgr->reg("NodeDug", SoundMaker::nodeDug, this); mgr->reg("NodeDug", SoundMaker::nodeDug, this);
mgr->reg("ObjectPunch", SoundMaker::objectPunch, this);
mgr->reg("PlayerDamage", SoundMaker::playerDamage, this); mgr->reg("PlayerDamage", SoundMaker::playerDamage, this);
mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this); mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this);
} }
@ -3978,7 +3971,6 @@ void Game::handlePointingAtObject(const PointedThing &pointed, const ItemStack &
} }
if (do_punch_damage) { if (do_punch_damage) {
client->event()->put(new SimpleTriggerEvent("ObjectPunch"));
// Report direct punch // Report direct punch
v3f objpos = runData.selected_object->getPosition(); v3f objpos = runData.selected_object->getPosition();
v3f dir = (objpos - player_position).normalize(); v3f dir = (objpos - player_position).normalize();