Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added noise support for reloading #12449

Merged
merged 4 commits into from May 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/SOUND_EFFECTS.txt
Expand Up @@ -27,4 +27,5 @@ close_door <furniture>|<terrain>
bash default
smash wall|door|door_boarded|glass
melee_hit <weapon> # note: use weapon id "null" for unarmed attacks
fire_gun <ammo>
fire_gun <weapon>
reload <weapon>
6 changes: 6 additions & 0 deletions src/activity_handlers.cpp
Expand Up @@ -913,6 +913,12 @@ void activity_handlers::reload_finish( player_activity *act, player *p )
add_msg(_("You reload your %s."), reloadable->tname().c_str());
p->recoil = MIN_RECOIL;
}

// Create noise.
if(reloadable->is_gun()) {
islot_gun* gun = reloadable->type->gun.get();
sounds::sound(p->pos(), gun->reload_noise_volume, gun->reload_noise, true, "reload", reloadable->typeId());
}
} else {
add_msg(m_info, _("Can't reload your %s."), reloadable->tname().c_str());
}
Expand Down
2 changes: 2 additions & 0 deletions src/item_factory.cpp
Expand Up @@ -620,6 +620,8 @@ void Item_factory::load( islot_gun &slot, JsonObject &jo )
slot.burst = jo.get_int( "burst", 0 );
slot.clip = jo.get_int( "clip_size" );
slot.reload_time = jo.get_int( "reload" );
slot.reload_noise = jo.get_string( "reload_noise", _ ("click.") );
slot.reload_noise_volume = jo.get_int( "reload_noise_volume", -1 );
slot.pierce = jo.get_int( "pierce", 0 );
slot.ammo_effects = jo.get_tags( "ammo_effects" );
slot.ups_charges = jo.get_int( "ups_charges", 0 );
Expand Down
8 changes: 8 additions & 0 deletions src/itype.h
Expand Up @@ -258,6 +258,14 @@ struct islot_gun : common_firing_data {
* Reload time.
*/
int reload_time = 0;
/**
* Noise displayed when reloading the weapon.
*/
std::string reload_noise;
/**
* Volume of the noise made when reloading this weapon.
*/
int reload_noise_volume = 0;
/**
* If this uses UPS charges, how many (per shoot), 0 for no UPS charges at all.
*/
Expand Down
8 changes: 4 additions & 4 deletions src/ranged.cpp
Expand Up @@ -1350,15 +1350,15 @@ void make_gun_sound_effect(player &p, bool burst, item *weapon)
}

if( ammo_used == "40mm") {
sounds::sound(p.pos(), 8, _("Thunk!"), false, "fire_gun", ammo_used);
sounds::sound(p.pos(), 8, _("Thunk!"), false, "fire_gun", weapon->typeId());
} else if( weapon_id == "hk_g80") {
sounds::sound(p.pos(), 24, _("tz-CRACKck!"), false, "fire_gun", ammo_used);
sounds::sound(p.pos(), 24, _("tz-CRACKck!"), false, "fire_gun", weapon->typeId());
} else if( ammo_used == "gasoline" || ammo_used == "66mm" ||
ammo_used == "84x246mm" || ammo_used == "m235" ) {
sounds::sound(p.pos(), 4, _("Fwoosh!"), false, "fire_gun", ammo_used);
sounds::sound(p.pos(), 4, _("Fwoosh!"), false, "fire_gun", weapon->typeId());
} else if( ammo_used != "bolt" && ammo_used != "arrow" && ammo_used != "pebble" &&
ammo_used != "fishspear" && ammo_used != "dart" ) {
sounds::sound(p.pos(), noise, gunsound, false, "fire_gun", ammo_used);
sounds::sound(p.pos(), noise, gunsound, false, "fire_gun", weapon->typeId());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sdltiles.cpp
Expand Up @@ -365,7 +365,7 @@ bool WinCreate()

// Set up audio mixer.
#ifdef SDL_SOUND
int audio_rate = 22050;
int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16;
int audio_channels = 2;
int audio_buffers = 4096;
Expand Down