Add better gun sfx and impact/miss sounds (#3899)

This commit is contained in:
Shadow
2022-04-18 17:33:02 -05:00
committed by GitHub
parent 8d30ae999b
commit 747d416d8c
62 changed files with 86 additions and 19 deletions

17
code/__DEFINES/guns.dm Normal file
View File

@@ -0,0 +1,17 @@
#define HOLD_CASINGS 0 //do not do anything after firing. Manual action, like pump shotguns, or guns that want to define custom behaviour
#define EJECT_CASINGS 2 //drop spent casings on the ground after firing
#define CYCLE_CASINGS 3 //cycle casings, like a revolver. Also works for multibarrelled guns
//Gun loading types
#define SINGLE_CASING 1 //The gun only accepts ammo_casings. ammo_magazines should never have this as their mag_type.
#define SPEEDLOADER 2 //Transfers casings from the mag to the gun when used.
#define MAGAZINE 4 //The magazine item itself goes inside the gun
#define BULLET_IMPACT_NONE "none"
#define BULLET_IMPACT_METAL "metal"
#define BULLET_IMPACT_MEAT "meat"
#define SOUNDS_BULLET_MEAT list('sound/effects/projectile_impact/bullet_meat1.ogg', 'sound/effects/projectile_impact/bullet_meat2.ogg', 'sound/effects/projectile_impact/bullet_meat3.ogg', 'sound/effects/projectile_impact/bullet_meat4.ogg')
#define SOUNDS_BULLET_METAL list('sound/effects/projectile_impact/bullet_metal1.ogg', 'sound/effects/projectile_impact/bullet_metal2.ogg', 'sound/effects/projectile_impact/bullet_metal3.ogg')
#define SOUNDS_LASER_MEAT list('sound/effects/projectile_impact/energy_meat1.ogg','sound/effects/projectile_impact/energy_meat2.ogg')
#define SOUNDS_LASER_METAL list('sound/effects/projectile_impact/energy_metal1.ogg','sound/effects/projectile_impact/energy_metal2.ogg')

View File

@@ -452,3 +452,6 @@
master.vis_contents -= src
master = null
return ..()
/atom/movable/proc/get_bullet_impact_effect_type()
return BULLET_IMPACT_NONE

View File

@@ -1247,6 +1247,9 @@
check_for_internal_damage(list(MECHA_INT_FIRE,MECHA_INT_TEMP_CONTROL,MECHA_INT_CONTROL_LOST,MECHA_INT_SHORT_CIRCUIT),1)
return
/mob/living/exosuit/get_bullet_impact_effect_type(def_zone)
return BULLET_IMPACT_METAL
/obj/mecha/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(exposed_temperature>src.max_temperature)
src.log_message("Exposed to dangerous temperature.",1)

View File

@@ -92,6 +92,9 @@
// redirect the projectile
Proj.redirect(new_x, new_y, curloc, null)
if(Proj.ricochet_sounds && prob(15))
playsound(src, pick(Proj.ricochet_sounds), 100, 1)
take_damage(damage)
return

View File

@@ -1670,3 +1670,11 @@
/mob/living/carbon/human/set_nutrition(amount)
nutrition = clamp(amount, 0, species.max_nutrition * 1.5)
/mob/living/carbon/human/get_bullet_impact_effect_type(var/def_zone)
var/obj/item/organ/external/E = get_organ(def_zone)
if(!E || E.is_stump())
return BULLET_IMPACT_NONE
if(BP_IS_ROBOTIC(E))
return BULLET_IMPACT_METAL
return BULLET_IMPACT_MEAT

View File

@@ -127,6 +127,10 @@
proj_sharp = 0
proj_edge = 0
var/list/impact_sounds = LAZYACCESS(P.impact_sounds, get_bullet_impact_effect_type(def_zone))
if(length(impact_sounds))
playsound(src, pick(impact_sounds), 75)
//Stun Beams
if(P.taser_effect)
stun_effect_act(0, P.agony, def_zone, P)
@@ -149,6 +153,9 @@
// return absorb
/mob/living/get_bullet_impact_effect_type(var/def_zone)
return BULLET_IMPACT_MEAT
//Handles the effects of "stun" weapons
/mob/living/proc/stun_effect_act(var/stun_amount, var/agony_amount, var/def_zone, var/used_weapon=null)
flash_pain()

View File

@@ -427,3 +427,6 @@
/mob/living/silicon/has_vision()
return 0 //NOT REAL EYES
/mob/living/silicon/get_bullet_impact_effect_type(var/def_zone)
return BULLET_IMPACT_METAL

View File

@@ -15,7 +15,8 @@
var/projectile_type //The bullet type to create when New() is called
var/obj/item/projectile/BB = null //The loaded bullet - make it so that the projectiles are created only when needed?
var/caseless = null //Caseless ammo deletes its self once the projectile is fired.
var/fall_sounds = list('sound/weapons/guns/casingfall1.ogg','sound/weapons/guns/casingfall2.ogg','sound/weapons/guns/casingfall3.ogg')
/obj/item/ammo_casing/Initialize(mapload)
. = ..()
if(ispath(projectile_type))
@@ -56,11 +57,6 @@
if (!BB)
. += "This one is spent."
//Gun loading types
#define SINGLE_CASING 1 //The gun only accepts ammo_casings. ammo_magazines should never have this as their mag_type.
#define SPEEDLOADER 2 //Transfers casings from the mag to the gun when used.
#define MAGAZINE 4 //The magazine item itself goes inside the gun
//An item that holds casings and can be used to put them inside guns
/obj/item/ammo_magazine
name = "magazine"

View File

@@ -251,6 +251,7 @@
caliber = "12g"
projectile_type = /obj/item/projectile/bullet/shotgun
matter = list(DEFAULT_WALL_MATERIAL = 360)
fall_sounds = list('sound/weapons/guns/shotgun_fall.ogg')
/obj/item/ammo_casing/a12g/pellet
name = "shotgun shell"

View File

@@ -77,6 +77,7 @@
var/sel_mode = 1 //index of the currently selected mode
var/list/firemodes = list()
var/selector_sound = 'sound/weapons/guns/selector.ogg'
//aiming system stuff
var/keep_aim = 1 //1 for keep shooting until aim is lowered
@@ -792,7 +793,7 @@
var/datum/firemode/new_mode = firemodes[sel_mode]
new_mode.apply_to(src)
to_chat(user, "<span class='notice'>\The [src] is now set to [new_mode.name].</span>")
playsound(loc, selector_sound, 50, 1)
return new_mode
/obj/item/gun/attack_self(mob/user)

View File

@@ -1,7 +1,3 @@
#define HOLD_CASINGS 0 //do not do anything after firing. Manual action, like pump shotguns, or guns that want to define custom behaviour
#define EJECT_CASINGS 1 //drop spent casings on the ground after firing
#define CYCLE_CASINGS 2 //experimental: cycle casings, like a revolver. Also works for multibarrelled guns
/obj/item/gun/projectile
name = "gun"
desc = "A gun that fires bullets."
@@ -21,6 +17,7 @@
var/max_shells = 0 //the number of casings that will fit inside
var/ammo_type = null //the type of ammo that the gun comes preloaded with
var/list/loaded = list() //stored ammo
var/load_sound = 'sound/weapons/guns/interaction/bullet_insert.ogg'
//For MAGAZINE guns
var/magazine_type = null //the type of magazine that the gun comes preloaded with
@@ -28,6 +25,8 @@
var/allowed_magazines //determines list of which magazines will fit in the gun
var/auto_eject = 0 //if the magazine should automatically eject itself when empty.
var/auto_eject_sound = null
var/mag_insert_sound = 'sound/weapons/guns/interaction/pistol_magin.ogg'
var/mag_remove_sound = 'sound/weapons/guns/interaction/pistol_magout.ogg'
var/can_special_reload = TRUE //Whether or not we can perform tactical/speed reloads on this gun
//TODO generalize ammo icon states for guns
//var/magazine_states = 0
@@ -141,14 +140,14 @@
user.visible_message(SPAN_WARNING("\The [user] reloads \the [src] with \the [AM]!"),
SPAN_WARNING("You speed reload \the [src] with \the [AM]!"))
ammo_magazine = AM
playsound(loc, "sound/weapons/flipblade.ogg", 75, 1)
playsound(loc, mag_insert_sound, 75, 1)
update_icon()
AM.update_icon()
user.remove_from_mob(AM)
AM.loc = src
ammo_magazine = AM
user.visible_message("[user] inserts [AM] into [src].", "<span class='notice'>You insert [AM] into [src].</span>")
playsound(src.loc, 'sound/weapons/flipblade.ogg', 50, 1)
playsound(src.loc, mag_insert_sound, 50, 1)
if(SPEEDLOADER)
if(loaded.len >= max_shells)
to_chat(user, "<span class='warning'>[src] is full!</span>")
@@ -164,7 +163,7 @@
count++
if(count)
user.visible_message("[user] reloads [src].", "<span class='notice'>You load [count] round\s into [src].</span>")
playsound(src.loc, 'sound/weapons/empty.ogg', 50, 1)
playsound(src.loc, 'sound/weapons/empty.ogg', 50, 1) //Kind of the opposite of empty but the "click" sound fits a speedloader nicely.
AM.update_icon()
else if(istype(A, /obj/item/ammo_casing))
var/obj/item/ammo_casing/C = A
@@ -178,7 +177,7 @@
C.loc = src
loaded.Insert(1, C) //add to the head of the list
user.visible_message("[user] inserts \a [C] into [src].", "<span class='notice'>You insert \a [C] into [src].</span>")
playsound(src.loc, 'sound/weapons/empty.ogg', 50, 1)
playsound(src.loc, load_sound, 50, 1)
else if(istype(A, /obj/item/storage))
var/obj/item/storage/storage = A
@@ -208,7 +207,7 @@
if(ammo_magazine)
user.put_in_hands(ammo_magazine)
user.visible_message("[user] removes [ammo_magazine] from [src].", "<span class='notice'>You remove [ammo_magazine] from [src].</span>")
playsound(src.loc, 'sound/weapons/empty.ogg', 50, 1)
playsound(src.loc, mag_remove_sound, 50, 1)
ammo_magazine.update_icon()
ammo_magazine = null
else if(loaded.len)

View File

@@ -5,7 +5,8 @@
load_method = SPEEDLOADER
ammo_type = /obj/item/ammo_casing/a9mm
projectile_type = /obj/item/projectile/bullet/pistol
mag_insert_sound = 'sound/weapons/guns/interaction/smg_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/smg_magout.ogg'
//Burst is the number of bullets fired; Fire delay is the time you have to wait to shoot the gun again, Move delay is the same but for moving after shooting. .
//Burst accuracy is the accuracy of each bullet fired in the burst. Dispersion is how much the bullets will 'spread' away from where you aimed.
@@ -81,6 +82,8 @@
magazine_type = /obj/item/ammo_magazine/m545
allowed_magazines = list(/obj/item/ammo_magazine/m545)
projectile_type = /obj/item/projectile/bullet/rifle/a545
mag_insert_sound = 'sound/weapons/guns/interaction/ltrifle_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/ltrifle_magout.ogg'
heavy = TRUE
one_handed_penalty = 30
@@ -141,6 +144,8 @@
projectile_type = /obj/item/projectile/bullet/rifle/a762
auto_eject = 1
auto_eject_sound = 'sound/weapons/smg_empty_alarm.ogg'
mag_insert_sound = 'sound/weapons/guns/interaction/batrifle_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/batrifle_magout.ogg'
heavy = TRUE
one_handed_penalty = 60
@@ -210,6 +215,8 @@
magazine_type = /obj/item/ammo_magazine/m545saw
allowed_magazines = list(/obj/item/ammo_magazine/m545saw, /obj/item/ammo_magazine/m545)
projectile_type = /obj/item/projectile/bullet/rifle/a545
mag_insert_sound = 'sound/weapons/guns/interaction/lmg_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/lmg_magout.ogg'
can_special_reload = FALSE
heavy = TRUE
one_handed_penalty = 90
@@ -292,7 +299,9 @@
projectile_type = /obj/item/projectile/bullet/shotgun
heavy = TRUE
one_handed_penalty = 30 //The AA12 can be fired one-handed fairly easily.
mag_insert_sound = 'sound/weapons/guns/interaction/lmg_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/lmg_magout.ogg'
firemodes = list(
list(mode_name="semiauto", burst=1, fire_delay=0),
list(mode_name="3-round bursts", burst=3, move_delay=6, burst_accuracy = list(60,40,30,25,15), dispersion = list(0.0, 0.6, 0.6))

View File

@@ -9,6 +9,8 @@
max_shells = 6
ammo_type = /obj/item/ammo_casing/a357
projectile_type = /obj/item/projectile/bullet/pistol/strong
mag_insert_sound = 'sound/weapons/guns/interaction/rev_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/rev_magout.ogg'
var/chamber_offset = 0 //how many empty chambers in the cylinder until you hit a round
/obj/item/gun/projectile/revolver/holy

View File

@@ -17,6 +17,7 @@
one_handed_penalty = 15
var/recentpump = 0 // to prevent spammage
var/action_sound = 'sound/weapons/shotgunpump.ogg'
load_sound = 'sound/weapons/guns/interaction/shotgun_insert.ogg'
var/animated_pump = 0 //This is for cyling animations.
var/empty_sprite = 0 //This is just a dirty var so it doesn't fudge up.

View File

@@ -17,6 +17,7 @@
max_shells = 1
ammo_type = /obj/item/ammo_casing/a145
projectile_type = /obj/item/projectile/bullet/rifle/a145
load_sound = 'sound/weapons/guns/interaction/rifle_load.ogg'
accuracy = -45
scoped_accuracy = 95
one_handed_penalty = 90
@@ -39,8 +40,10 @@
chambered = null
else
to_chat(user, "<span class='notice'>You work the bolt open.</span>")
playsound(src.loc, 'sound/weapons/guns/interaction/rifle_boltback.ogg', 50, 1)
else
to_chat(user, "<span class='notice'>You work the bolt closed.</span>")
playsound(src.loc, 'sound/weapons/guns/interaction/rifle_boltforward.ogg', 50, 1)
bolt_open = 0
add_fingerprint(user)
update_icon()

View File

@@ -46,6 +46,10 @@
var/impact_type
var/datum/beam_components_cache/beam_components
var/miss_sounds
var/ricochet_sounds
var/list/impact_sounds //for different categories, IMPACT_MEAT etc
//Fancy hitscan lighting effects!
var/hitscan_light_intensity = 1.5
var/hitscan_light_range = 0.75
@@ -650,6 +654,7 @@
if(result == PROJECTILE_FORCE_MISS)
if(!silenced)
visible_message("<span class='notice'>\The [src] misses [target_mob] narrowly!</span>")
playsound(target_mob.loc, pick(miss_sounds), 60, 1)
return FALSE
//hit messages

View File

@@ -13,7 +13,8 @@
light_range = 2
light_power = 0.5
light_color = "#FF0D00"
impact_sounds = list(BULLET_IMPACT_MEAT = SOUNDS_LASER_MEAT, BULLET_IMPACT_METAL = SOUNDS_LASER_METAL)
muzzle_type = /obj/effect/projectile/muzzle/laser
tracer_type = /obj/effect/projectile/tracer/laser
impact_type = /obj/effect/projectile/impact/laser

View File

@@ -11,6 +11,10 @@
var/mob_passthrough_check = 0
muzzle_type = /obj/effect/projectile/muzzle/bullet
miss_sounds = list('sound/weapons/guns/miss1.ogg','sound/weapons/guns/miss2.ogg','sound/weapons/guns/miss3.ogg','sound/weapons/guns/miss4.ogg')
ricochet_sounds = list('sound/weapons/guns/ricochet1.ogg', 'sound/weapons/guns/ricochet2.ogg',
'sound/weapons/guns/ricochet3.ogg', 'sound/weapons/guns/ricochet4.ogg')
impact_sounds = list(BULLET_IMPACT_MEAT = SOUNDS_BULLET_MEAT, BULLET_IMPACT_METAL = SOUNDS_BULLET_METAL)
/obj/item/projectile/bullet/on_hit(var/atom/target, var/blocked = 0)
if (..(target, blocked))

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -37,6 +37,7 @@
#include "code\__DEFINES\directional.dm"
#include "code\__DEFINES\dna.dm"
#include "code\__DEFINES\gamemode.dm"
#include "code\__DEFINES\guns.dm"
#include "code\__DEFINES\holidays.dm"
#include "code\__DEFINES\holomap.dm"
#include "code\__DEFINES\icon_smoothing.dm"