dig, place, and jump sounds

This commit is contained in:
darkrose 2014-08-19 19:09:02 +10:00
parent c255099ec1
commit c755aec1b3
16 changed files with 78 additions and 12 deletions

BIN
data/sounds/dig_dirt.1.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
data/sounds/dig_plant.1.ogg Normal file

Binary file not shown.

BIN
data/sounds/dig_stone.1.ogg Normal file

Binary file not shown.

BIN
data/sounds/dig_wood.1.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -189,6 +189,7 @@ Client::Client(
ISoundManager *sound):
m_mesh_update_thread(),
m_env(
this,
new ClientMap(this, control,
device->getSceneManager()->getRootSceneNode(),
device->getSceneManager(), 666),
@ -199,6 +200,7 @@ Client::Client(
m_device(device),
m_server_ser_ver(SER_FMT_VER_INVALID),
m_inventory_updated(false),
m_pointed_node(-32768,-32768,-32768),
m_time_of_day(0),
m_map_seed(0),
m_password(password),
@ -1573,6 +1575,8 @@ void Client::groundAction(u8 action, v3s16 nodepos_undersurface,
writeV3S16(&data[9], nodepos_oversurface);
writeU16(&data[15], item);
Send(0, data, true);
if (action == 3)
playDigSound();
}
void Client::clickActiveObject(u8 button, u16 id, u16 item_i)
@ -2256,6 +2260,13 @@ void Client::playStepSound()
if (!m_sound)
return;
f32 volume = g_settings->getFloat("sound_volume");
if (volume < 1.0)
return;
if (volume > 100.0)
volume = 100.0;
volume /= 100.0;
v3f pf = m_env.getLocalPlayer()->getPosition();
v3s16 pp = floatToInt(pf + v3f(0, BS*0.1, 0), BS);
MapNode n = m_env.getMap().getNodeNoEx(pp);
@ -2265,19 +2276,19 @@ void Client::playStepSound()
}
switch (content_features(n).type) {
case CMT_PLANT:
m_sound->playSound("plant-walk",false,1.0);
m_sound->playSound("plant-walk",false,volume);
break;
case CMT_DIRT:
m_sound->playSound("dirt-walk",false,1.0);
m_sound->playSound("dirt-walk",false,volume);
break;
case CMT_STONE:
m_sound->playSound("stone-walk",false,1.0);
m_sound->playSound("stone-walk",false,volume);
break;
case CMT_LIQUID:
m_sound->playSound("liquid-walk",false,1.0);
m_sound->playSound("liquid-walk",false,volume);
break;
case CMT_WOOD:
m_sound->playSound("wood-walk",false,1.0);
m_sound->playSound("wood-walk",false,volume);
break;
default:;
}
@ -2287,13 +2298,45 @@ void Client::playDigSound()
{
if (!m_sound)
return;
printf("dig\n");
f32 volume = g_settings->getFloat("sound_volume");
if (volume < 1.0)
return;
if (volume > 100.0)
volume = 100.0;
volume /= 100.0;
v3s16 p = getPointedNode();
MapNode n = m_env.getMap().getNodeNoEx(p);
switch (content_features(n).type) {
case CMT_PLANT:
m_sound->playSound("plant-dig",false,volume);
break;
case CMT_DIRT:
m_sound->playSound("dirt-dig",false,volume);
break;
case CMT_STONE:
m_sound->playSound("stone-dig",false,volume);
break;
case CMT_LIQUID:
m_sound->playSound("liquid-dig",false,volume);
break;
case CMT_WOOD:
m_sound->playSound("wood-dig",false,volume);
break;
default:;
}
}
void Client::playPlaceSound()
{
if (!m_sound)
return;
printf("place\n");
}
f32 volume = g_settings->getFloat("sound_volume");
if (volume < 1.0)
return;
if (volume > 100.0)
volume = 100.0;
volume /= 100.0;
m_sound->playSound("place",false,volume);
}

View File

@ -325,6 +325,9 @@ public:
void playDigSound();
void playPlaceSound();
void setPointedNode(v3s16 p) {m_pointed_node = p;}
v3s16 getPointedNode() {return m_pointed_node;}
private:
// Virtual methods from con::PeerHandler
@ -364,6 +367,7 @@ private:
bool m_inventory_updated;
core::map<v3s16, bool> m_active_blocks;
v3s16 m_pointed_node;
PacketCounter m_packetcounter;

View File

@ -96,6 +96,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("anisotropic_filter", "true");
settings->setDefault("bilinear_filter", "false");
settings->setDefault("trilinear_filter", "false");
settings->setDefault("sound_volume", "50");
// Server stuff
// "map-dir" doesn't exist by default.

View File

@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "profiler.h"
#include "server.h"
#include "client.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@ -3775,7 +3776,8 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
ClientEnvironment
*/
ClientEnvironment::ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr):
ClientEnvironment::ClientEnvironment(Client *client, ClientMap *map, scene::ISceneManager *smgr):
m_client(client),
m_map(map),
m_smgr(smgr)
{
@ -3938,11 +3940,12 @@ void ClientEnvironment::step(float dtime)
i != player_collisions.end(); i++)
{
CollisionInfo &info = *i;
if(info.t == COLLISION_FALL)
{
if (info.t == COLLISION_FALL) {
//f32 tolerance = BS*10; // 2 without damage
f32 tolerance = BS*12; // 3 without damage
f32 factor = 1;
if (info.speed > tolerance/2.0)
m_client->playStepSound();
if(info.speed > tolerance)
{
f32 damage_f = (info.speed - tolerance)/BS*factor;

View File

@ -349,10 +349,12 @@ struct ClientEnvEvent
};
};
class Client;
class ClientEnvironment : public Environment
{
public:
ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr);
ClientEnvironment(Client *client, ClientMap *map, scene::ISceneManager *smgr);
~ClientEnvironment();
Map & getMap()
@ -428,6 +430,7 @@ public:
ClientEnvEvent getClientEvent();
private:
Client *m_client;
ClientMap *m_map;
scene::ISceneManager *m_smgr;
core::map<u16, ClientActiveObject*> m_active_objects;

View File

@ -611,6 +611,8 @@ void getPointedNode(Client *client, v3f player_position,
} // for dirs
} // regular block
} // for coords
if (nodefound)
client->setPointedNode(nodepos);
}
void update_skybox(video::IVideoDriver* driver,

View File

@ -53,12 +53,20 @@ void init_sounds(ISoundManager *sound)
// digging
// CMT_DIRT
sound->loadSound("dirt-dig","dig_dirt.1.ogg");
// CMT_STONE
sound->loadSound("stone-dig","dig_stone.1.ogg");
// CMT_PLANT
sound->loadSound("plant-dig","dig_plant.1.ogg");
// CMT_LIQUID
sound->loadSound("liquid-dig","dig_liquid.1.ogg");
// CMT_WOOD
sound->loadSound("wood-dig","dig_wood.1.ogg");
// placing
sound->loadSound("place","place_node.1.ogg");
sound->loadSound("place","place_node.2.ogg");
sound->loadSound("place","place_node.3.ogg");
// CMT_DIRT
// CMT_STONE
// CMT_PLANT

View File

@ -118,6 +118,8 @@
#trilinear_filter = false
# How to show the node being pointed at (outline or hilight)
#selected_node = hilight
# Volume for sound effects (0-100)
#sound_volume = 50
#
# Server stuff