* Honkbots 0.9.0 Old code, needs testing. * Honkbots 0.9.1 Small Fixes - Part 1 * Honkbot 0.9.1b Fixes * Honkbots 0.9.2 Added sound cooldown, fixes. * Honkbots 0.9.5 Clown Box & Honkbot Assembly Code * 0.9.5.a oops * Honkbots 1.0.0 Final touches and fixes. Clown Box finished. Assembly functioning. Honkbots tested and ready to go. Its time. * Honkbots 1.0.1 Initialize and . = ..() * Honkbots 1.0.2 Fixes and Changes ==== Nerfed Brute/Thermal Resist Buffed Health (to avoid 1-shot) Added HONK_BOT define * Honkbots 1.0.3 Removed the cardboard assembly from death gibs. Admin Bwoink removed from emagged soundtrack. Honkbot now release an evil laugh when emagged. Fixed strange behaviors on emagged level 1 Added a check against stamping multiple cardboard sheets. Stamping a Clown Box now plays the bike horn, once. Clown Boxes no longer get automatically placed in hands. Various other fixes. * Honkbots 1.0.3a * Honkbots 1.0.3.b Fixes. * Honkbots 1.0.4 *Added an emote ping upon assembly creation. *Enabled either Theatre or Robotics for access. ((fixing needing both)) *Honkbots are now more forgiving after being hit. **Airhorn stun_attack now deals slight ear damage, for about 5 seconds. **Cardboard no longer drops upon death. Robot arms have 50% chance. **Using a new get_sfx() list when emagged. **Optimization and other minor fixes. * Honkbots 1.0.4.a Missed it. * Honkbots 1.0.4.b use(1) and (client) * Honkbots 1.0.4.c Moved proc * Honkbots 1.0.5 *Code Optimization *Renaming w/ Pen (how could I even forget this) *Assembly Defines I'm afraid I'm simply out of my depth with the suggested use(1) rework. * Honkbots 1.0.5.c Reworked cardboard stamping. It now works in the hands and on the ground, either solo or in stacks, and prevent itself being used in backpacks. * Honkbots 1.0.5.d Final * Honkbots 1.0.5.e comment * 1.0.5.f Optimization * Honkbots 1.0.5.g Missed requested stuff * Honkbots 1.0.6 Requested changes. * Honkbots 1.0.6a Oops. * Honkbots 1.0.6.c Bugfix - Prevent building in backpacks. Make sure they spawn on turf. * Honkbots 1.0.7 one less spawn(0) flag optimization else return ..() * Honkbots 1.0.7.a Get rids of a lot of client checks at the cost of automatic AI retoration. * Honkbots 1.0.7.b Added judgment_criteria() changed assess_threat to use judgment * Honkbots 1.0.7.c final = NONE
186 lines
9.4 KiB
Plaintext
186 lines
9.4 KiB
Plaintext
/proc/playsound(atom/source, soundin, vol as num, vary, extrarange as num, falloff, frequency = null, channel = 0, pressure_affected = TRUE)
|
|
if(isarea(source))
|
|
throw EXCEPTION("playsound(): source is an area")
|
|
return
|
|
|
|
var/turf/turf_source = get_turf(source)
|
|
|
|
//allocate a channel if necessary now so its the same for everyone
|
|
channel = channel || open_sound_channel()
|
|
|
|
// Looping through the player list has the added bonus of working for mobs inside containers
|
|
var/sound/S = sound(get_sfx(soundin))
|
|
var/maxdistance = (world.view + extrarange) * 3
|
|
for(var/P in GLOB.player_list)
|
|
var/mob/M = P
|
|
if(!M || !M.client)
|
|
continue
|
|
var/distance = get_dist(M, turf_source)
|
|
|
|
if(distance <= maxdistance)
|
|
var/turf/T = get_turf(M)
|
|
|
|
if(T && T.z == turf_source.z)
|
|
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, channel, pressure_affected, S)
|
|
|
|
/mob/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, channel = 0, pressure_affected = TRUE, sound/S)
|
|
if(!client || !can_hear())
|
|
return
|
|
|
|
if(!S)
|
|
S = sound(get_sfx(soundin))
|
|
|
|
S.wait = 0 //No queue
|
|
S.channel = channel || open_sound_channel()
|
|
S.volume = vol
|
|
|
|
if(vary)
|
|
if(frequency)
|
|
S.frequency = frequency
|
|
else
|
|
S.frequency = get_rand_frequency()
|
|
|
|
if(isturf(turf_source))
|
|
var/turf/T = get_turf(src)
|
|
|
|
//sound volume falloff with distance
|
|
var/distance = get_dist(T, turf_source)
|
|
|
|
S.volume -= max(distance - world.view, 0) * 2 //multiplicative falloff to add on top of natural audio falloff.
|
|
|
|
if(pressure_affected)
|
|
//Atmosphere affects sound
|
|
var/pressure_factor = 1
|
|
var/datum/gas_mixture/hearer_env = T.return_air()
|
|
var/datum/gas_mixture/source_env = turf_source.return_air()
|
|
|
|
if(hearer_env && source_env)
|
|
var/pressure = min(hearer_env.return_pressure(), source_env.return_pressure())
|
|
if(pressure < ONE_ATMOSPHERE)
|
|
pressure_factor = max((pressure - SOUND_MINIMUM_PRESSURE)/(ONE_ATMOSPHERE - SOUND_MINIMUM_PRESSURE), 0)
|
|
else //space
|
|
pressure_factor = 0
|
|
|
|
if(distance <= 1)
|
|
pressure_factor = max(pressure_factor, 0.15) //touching the source of the sound
|
|
|
|
S.volume *= pressure_factor
|
|
//End Atmosphere affecting sound
|
|
|
|
if(S.volume <= 0)
|
|
return //No sound
|
|
|
|
var/dx = turf_source.x - T.x // Hearing from the right/left
|
|
S.x = dx
|
|
var/dz = turf_source.y - T.y // Hearing from infront/behind
|
|
S.z = dz
|
|
// The y value is for above your head, but there is no ceiling in 2d spessmens.
|
|
S.y = 1
|
|
S.falloff = (falloff ? falloff : FALLOFF_SOUNDS)
|
|
|
|
SEND_SOUND(src, S)
|
|
|
|
/proc/sound_to_playing_players(soundin, volume = 100, vary = FALSE, frequency = 0, falloff = FALSE, channel = 0, pressure_affected = FALSE, sound/S)
|
|
if(!S)
|
|
S = sound(get_sfx(soundin))
|
|
for(var/m in GLOB.player_list)
|
|
if(ismob(m) && !isnewplayer(m))
|
|
var/mob/M = m
|
|
M.playsound_local(M, null, volume, vary, frequency, falloff, channel, pressure_affected, S)
|
|
|
|
/proc/open_sound_channel()
|
|
var/static/next_channel = 1 //loop through the available 1024 - (the ones we reserve) channels and pray that its not still being used
|
|
. = ++next_channel
|
|
if(next_channel > CHANNEL_HIGHEST_AVAILABLE)
|
|
next_channel = 1
|
|
|
|
/mob/proc/stop_sound_channel(chan)
|
|
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = chan))
|
|
|
|
/client/proc/playtitlemusic(vol = 85)
|
|
set waitfor = FALSE
|
|
UNTIL(SSticker.login_music) //wait for SSticker init to set the login music
|
|
|
|
if(prefs && (prefs.toggles & SOUND_LOBBY))
|
|
SEND_SOUND(src, sound(SSticker.login_music, repeat = 0, wait = 0, volume = vol, channel = CHANNEL_LOBBYMUSIC) // MAD JAMS)
|
|
|
|
/proc/get_rand_frequency()
|
|
return rand(32000, 55000) //Frequency stuff only works with 45kbps oggs.
|
|
|
|
/proc/get_sfx(soundin)
|
|
if(istext(soundin))
|
|
switch(soundin)
|
|
if ("shatter")
|
|
soundin = pick('sound/effects/glassbr1.ogg','sound/effects/glassbr2.ogg','sound/effects/glassbr3.ogg')
|
|
if ("explosion")
|
|
soundin = pick('sound/effects/explosion1.ogg','sound/effects/explosion2.ogg')
|
|
if ("sparks")
|
|
soundin = pick('sound/effects/sparks1.ogg','sound/effects/sparks2.ogg','sound/effects/sparks3.ogg','sound/effects/sparks4.ogg')
|
|
if ("rustle")
|
|
soundin = pick('sound/effects/rustle1.ogg','sound/effects/rustle2.ogg','sound/effects/rustle3.ogg','sound/effects/rustle4.ogg','sound/effects/rustle5.ogg')
|
|
if ("bodyfall")
|
|
soundin = pick('sound/effects/bodyfall1.ogg','sound/effects/bodyfall2.ogg','sound/effects/bodyfall3.ogg','sound/effects/bodyfall4.ogg')
|
|
if ("punch")
|
|
soundin = pick('sound/weapons/punch1.ogg','sound/weapons/punch2.ogg','sound/weapons/punch3.ogg','sound/weapons/punch4.ogg')
|
|
if ("clownstep")
|
|
soundin = pick('sound/effects/clownstep1.ogg','sound/effects/clownstep2.ogg')
|
|
if ("suitstep")
|
|
soundin = pick('sound/effects/suitstep1.ogg','sound/effects/suitstep2.ogg')
|
|
if ("swing_hit")
|
|
soundin = pick('sound/weapons/genhit1.ogg', 'sound/weapons/genhit2.ogg', 'sound/weapons/genhit3.ogg')
|
|
if ("hiss")
|
|
soundin = pick('sound/voice/hiss1.ogg','sound/voice/hiss2.ogg','sound/voice/hiss3.ogg','sound/voice/hiss4.ogg')
|
|
if ("pageturn")
|
|
soundin = pick('sound/effects/pageturn1.ogg', 'sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg')
|
|
if ("gunshot")
|
|
soundin = pick('sound/weapons/gunshot.ogg', 'sound/weapons/gunshot2.ogg','sound/weapons/gunshot3.ogg','sound/weapons/gunshot4.ogg')
|
|
if ("ricochet")
|
|
soundin = pick( 'sound/weapons/effects/ric1.ogg', 'sound/weapons/effects/ric2.ogg','sound/weapons/effects/ric3.ogg','sound/weapons/effects/ric4.ogg','sound/weapons/effects/ric5.ogg')
|
|
if ("terminal_type")
|
|
soundin = pick('sound/machines/terminal_button01.ogg', 'sound/machines/terminal_button02.ogg', 'sound/machines/terminal_button03.ogg', \
|
|
'sound/machines/terminal_button04.ogg', 'sound/machines/terminal_button05.ogg', 'sound/machines/terminal_button06.ogg', \
|
|
'sound/machines/terminal_button07.ogg', 'sound/machines/terminal_button08.ogg')
|
|
if ("desceration")
|
|
soundin = pick('sound/misc/desceration-01.ogg', 'sound/misc/desceration-02.ogg', 'sound/misc/desceration-03.ogg')
|
|
if ("im_here")
|
|
soundin = pick('sound/hallucinations/im_here1.ogg', 'sound/hallucinations/im_here2.ogg')
|
|
if ("can_open")
|
|
soundin = pick('sound/effects/can_open1.ogg', 'sound/effects/can_open2.ogg', 'sound/effects/can_open3.ogg')
|
|
if ("struggle_sound")
|
|
soundin = pick( 'sound/vore/pred/struggle_01.ogg','sound/vore/pred/struggle_02.ogg','sound/vore/pred/struggle_03.ogg',
|
|
'sound/vore/pred/struggle_04.ogg','sound/vore/pred/struggle_05.ogg')
|
|
if ("prey_struggle")
|
|
soundin = pick( 'sound/vore/prey/struggle_01.ogg','sound/vore/prey/struggle_02.ogg','sound/vore/prey/struggle_03.ogg',
|
|
'sound/vore/prey/struggle_04.ogg','sound/vore/prey/struggle_05.ogg')
|
|
if ("digest_pred")
|
|
soundin = pick( 'sound/vore/pred/digest_01.ogg','sound/vore/pred/digest_02.ogg','sound/vore/pred/digest_03.ogg',
|
|
'sound/vore/pred/digest_04.ogg','sound/vore/pred/digest_05.ogg','sound/vore/pred/digest_06.ogg',
|
|
'sound/vore/pred/digest_07.ogg','sound/vore/pred/digest_08.ogg','sound/vore/pred/digest_09.ogg',
|
|
'sound/vore/pred/digest_10.ogg','sound/vore/pred/digest_11.ogg','sound/vore/pred/digest_12.ogg',
|
|
'sound/vore/pred/digest_13.ogg','sound/vore/pred/digest_14.ogg','sound/vore/pred/digest_15.ogg',
|
|
'sound/vore/pred/digest_16.ogg','sound/vore/pred/digest_17.ogg','sound/vore/pred/digest_18.ogg')
|
|
if ("death_pred")
|
|
soundin = pick( 'sound/vore/pred/death_01.ogg','sound/vore/pred/death_02.ogg','sound/vore/pred/death_03.ogg',
|
|
'sound/vore/pred/death_04.ogg','sound/vore/pred/death_05.ogg','sound/vore/pred/death_06.ogg',
|
|
'sound/vore/pred/death_07.ogg','sound/vore/pred/death_08.ogg','sound/vore/pred/death_09.ogg',
|
|
'sound/vore/pred/death_10.ogg')
|
|
if ("digest_prey")
|
|
soundin = pick( 'sound/vore/prey/digest_01.ogg','sound/vore/prey/digest_02.ogg','sound/vore/prey/digest_03.ogg',
|
|
'sound/vore/prey/digest_04.ogg','sound/vore/prey/digest_05.ogg','sound/vore/prey/digest_06.ogg',
|
|
'sound/vore/prey/digest_07.ogg','sound/vore/prey/digest_08.ogg','sound/vore/prey/digest_09.ogg',
|
|
'sound/vore/prey/digest_10.ogg','sound/vore/prey/digest_11.ogg','sound/vore/prey/digest_12.ogg',
|
|
'sound/vore/prey/digest_13.ogg','sound/vore/prey/digest_14.ogg','sound/vore/prey/digest_15.ogg',
|
|
'sound/vore/prey/digest_16.ogg','sound/vore/prey/digest_17.ogg','sound/vore/prey/digest_18.ogg')
|
|
if ("death_prey")
|
|
soundin = pick( 'sound/vore/prey/death_01.ogg','sound/vore/prey/death_02.ogg','sound/vore/prey/death_03.ogg',
|
|
'sound/vore/prey/death_04.ogg','sound/vore/prey/death_05.ogg','sound/vore/prey/death_06.ogg',
|
|
'sound/vore/prey/death_07.ogg','sound/vore/prey/death_08.ogg','sound/vore/prey/death_09.ogg',
|
|
'sound/vore/prey/death_10.ogg')
|
|
if("bullet_miss")
|
|
soundin = pick('sound/weapons/bulletflyby.ogg', 'sound/weapons/bulletflyby2.ogg', 'sound/weapons/bulletflyby3.ogg')
|
|
if("law")
|
|
soundin = pick('sound/voice/bgod.ogg', 'sound/voice/biamthelaw.ogg', 'sound/voice/bsecureday.ogg', 'sound/voice/bradio.ogg', 'sound/voice/binsult.ogg', 'sound/voice/bcreep.ogg')
|
|
if("honkbot_e")
|
|
soundin = pick('sound/items/bikehorn.ogg', 'sound/items/AirHorn2.ogg', 'sound/misc/sadtrombone.ogg', 'sound/items/AirHorn.ogg', 'sound/effects/reee.ogg', 'sound/items/WEEOO1.ogg', 'sound/voice/biamthelaw.ogg', 'sound/voice/bcreep.ogg','sound/magic/Fireball.ogg' ,'sound/effects/pray.ogg', 'sound/voice/hiss1.ogg','sound/machines/buzz-sigh.ogg', 'sound/machines/ping.ogg', 'sound/weapons/flashbang.ogg', 'sound/weapons/bladeslice.ogg')
|
|
return soundin
|