Skip to content

Commit

Permalink
Merge pull request #590 from tigercat2000/HeartBeatPort
Browse files Browse the repository at this point in the history
Heartbeat sound port from Baystation12/Baystation12#8386
  • Loading branch information
ZomgPonies committed Mar 19, 2015
2 parents 3fc1941 + 4cd7148 commit ab619f6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
16 changes: 15 additions & 1 deletion code/modules/client/preferences_toggles.dm
Expand Up @@ -25,7 +25,7 @@
src << "As a ghost, you will now [(prefs.toggles & CHAT_GHOSTRADIO) ? "hear all radio chat in the world" : "only hear from nearby speakers"]."
prefs.save_preferences(src)
feedback_add_details("admin_verb","TGR")

/client/proc/toggle_hear_radio()
set name = "Show/Hide RadioChatter"
set category = "Preferences"
Expand Down Expand Up @@ -134,6 +134,20 @@
src << sound(null, repeat = 0, wait = 0, volume = 0, channel = 2)
feedback_add_details("admin_verb","TAmbi") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

/client/verb/Toggle_Heartbeat() //to toggle off heartbeat sounds, in case they get too annoying
set name = "Hear/Silence Heartbeat"
set category = "Preferences"
set desc = "Toggles hearing heart beating sound effects"
prefs.sound ^= SOUND_HEARTBEAT
prefs.save_preferences(src)
if(prefs.sound & SOUND_HEARTBEAT)
src << "You will now hear heartbeat sounds."
else
src << "You will no longer hear heartbeat sounds."
src << sound(null, repeat = 0, wait = 0, volume = 0, channel = 1)
src << sound(null, repeat = 0, wait = 0, volume = 0, channel = 2)
feedback_add_details("admin_verb","Thb") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

//be special
/client/verb/toggle_be_special(role in be_special_flags)
set name = "Toggle Special Role Candidacy"
Expand Down
51 changes: 51 additions & 0 deletions code/modules/mob/living/carbon/human/life.dm
Expand Up @@ -35,6 +35,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
var/in_stasis = 0
var/exposedtimenow = 0
var/firstexposed = 0
var/heartbeat = 0

/mob/living/carbon/human/Life()
set invisibility = 0
Expand Down Expand Up @@ -110,6 +111,8 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc

handle_medical_side_effects()

handle_heartbeat()

if(stat == DEAD)
handle_decay()

Expand Down Expand Up @@ -498,6 +501,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
//Body temperature is too hot.
fire_alert = max(fire_alert, 1)
if(status_flags & GODMODE) return 1 //godmode

if(bodytemperature >= species.heat_level_1 && bodytemperature <= species.heat_level_2)
take_overall_damage(burn=HEAT_DAMAGE_LEVEL_1, used_weapon = "High Body Temperature")
fire_alert = max(fire_alert, 2)
Expand All @@ -515,7 +519,9 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
else if(bodytemperature < species.cold_level_1)
fire_alert = max(fire_alert, 1)
if(status_flags & GODMODE) return 1 //godmode

if(stat == DEAD) return 1 //ZomgPonies -- No need for cold burn damage if dead

if(!istype(loc, /obj/machinery/atmospherics/unary/cryo_cell))
if(bodytemperature >= species.cold_level_2 && bodytemperature <= species.cold_level_1)
take_overall_damage(burn=COLD_DAMAGE_LEVEL_1, used_weapon = "Low Body Temperature")
Expand Down Expand Up @@ -1646,6 +1652,46 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
H << "<spawn class='warning'>You smell something foul..."
H.vomit()

proc/handle_heartbeat()
var/client/C = src.client
if(C && C.prefs.sound & SOUND_HEARTBEAT) //disable heartbeat by pref
var/datum/organ/internal/heart/H = internal_organs_by_name["heart"]
if(istype(H,/datum/organ/internal/heart/robotic)) //Handle robotic hearts specially with a wuuuubb. This also applies to machine-people.
if(shock_stage >= 10 || istype(get_turf(src), /turf/space))
//PULSE_THREADY - maximum value for pulse, currently it 5.
//High pulse value corresponds to a fast rate of heartbeat.
//Divided by 2, otherwise it is too slow.
var/rate = (PULSE_THREADY - 2)/2 //machine people (main target) have no pulse, manually subtract standard human pulse (2). Mechanic-heart humans probably have a pulse, but 'advanced neural systems' keep the heart rate steady, or something

if(heartbeat >= rate)
heartbeat = 0
src << sound('sound/effects/electheart.ogg',0,0,0,30) //Credit to GhostHack (www.ghosthack.de) for sound.
else
heartbeat++
return
return

if(pulse == PULSE_NONE)
return

if(!H)
return

if(pulse >= PULSE_2FAST || shock_stage >= 10 || istype(get_turf(src), /turf/space))
//PULSE_THREADY - maximum value for pulse, currently it 5.
//High pulse value corresponds to a fast rate of heartbeat.
//Divided by 2, otherwise it is too slow.
var/rate = (PULSE_THREADY - pulse)/2

if(heartbeat >= rate)
heartbeat = 0
if(istype(H,/datum/organ/internal/heart/assisted))
src << sound('sound/effects/pacemakebeat.ogg',0,0,0,50)
else
src << sound('sound/effects/singlebeat.ogg',0,0,0,50)
else
heartbeat++

/*
Called by life(), instead of having the individual hud items update icons each tick and check for status changes
we only set those statuses and icons upon changes. Then those HUD items will simply add those pre-made images.
Expand All @@ -1664,6 +1710,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc

hud_list[HEALTH_HUD] = holder


if(hud_updateflag & 1 << STATUS_HUD)
var/foundVirus = 0
for (var/ID in virus2)
Expand Down Expand Up @@ -1698,6 +1745,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
hud_list[STATUS_HUD] = holder
hud_list[STATUS_HUD_OOC] = holder2


if(hud_updateflag & 1 << ID_HUD)
var/image/holder = hud_list[ID_HUD]
if(wear_id)
Expand All @@ -1712,6 +1760,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc

hud_list[ID_HUD] = holder


if(hud_updateflag & 1 << WANTED_HUD)
var/image/holder = hud_list[WANTED_HUD]
holder.icon_state = "hudblank"
Expand All @@ -1737,6 +1786,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
break
hud_list[WANTED_HUD] = holder


if(hud_updateflag & 1 << IMPLOYAL_HUD || hud_updateflag & 1 << IMPCHEM_HUD || hud_updateflag & 1 << IMPTRACK_HUD)
var/image/holder1 = hud_list[IMPTRACK_HUD]
var/image/holder2 = hud_list[IMPLOYAL_HUD]
Expand Down Expand Up @@ -1848,6 +1898,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
speech_problem_flag = 1
return stuttering


// Need this in species.
//#undef HUMAN_MAX_OXYLOSS
//#undef HUMAN_CRIT_MAX_OXYLOSS
3 changes: 2 additions & 1 deletion code/setup.dm
Expand Up @@ -725,8 +725,9 @@ var/list/TAGGERLOCATIONS = list("Disposals",
#define SOUND_AMBIENCE 4
#define SOUND_LOBBY 8
#define SOUND_STREAMING 16
#define SOUND_HEARTBEAT 32

#define SOUND_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|SOUND_STREAMING)
#define SOUND_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|SOUND_STREAMING|SOUND_HEARTBEAT)
#define TOGGLES_DEFAULT (CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|CHAT_ATTACKLOGS|CHAT_LOOC)

#define BE_TRAITOR 1
Expand Down
Binary file added sound/effects/electheart.ogg
Binary file not shown.
Binary file added sound/effects/pacemakebeat.ogg
Binary file not shown.
Binary file added sound/effects/singlebeat.ogg
Binary file not shown.

0 comments on commit ab619f6

Please sign in to comment.