Add 'silent' armor group

master
stujones11 2019-06-23 20:53:31 +01:00 committed by MoNTE48
parent e7befeecdc
commit 528f7f0be9
3 changed files with 8 additions and 9 deletions

View File

@ -103,7 +103,7 @@ core.register_entity(":__builtin:item", {
else
self.itemstring = staticdata
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_acceleration({x = 0, y = -gravity, z = 0})
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 "wieldmesh.h"
#include "log.h"
#include "itemgroup.h"
#include <algorithm>
class Settings;
@ -1790,6 +1791,12 @@ bool GenericCAO::directReportPunch(v3f dir, const ItemStack *punchitem,
punchitem,
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.damage < m_hp)

View File

@ -545,12 +545,6 @@ 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;
@ -571,7 +565,6 @@ 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);
}
@ -3978,7 +3971,6 @@ 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();