Skip to content

Commit

Permalink
PKP Mind Virus: Glorfing Cigs edition (tgstation#69904)
Browse files Browse the repository at this point in the history
* PKP Mind Virus: Glorfing Cigs edition

If you glorf while smoking you'll get the cig stuck in your throat, leaving you unable to breath, speak, or eat. Based off the sort of cig you have a random delay before you vomit up the cig. (Pipes last forever don't philoso-larp kids). Other players can help you by using the help action on you while you're hurt, which leads to something imitating the himelich manuver, a broken chest, and a vomited up blockage. Other forms of vomiting will work too, if that's even applicable.

Oh I fixed a bug in vomit code. Because paralyzing you forces you to the ground, thus changing your dir, paralyzing vomits always went down. This is cringe, easy fix tho.

Ah and I added some extra functionality to sound loops too. You can set them to pick and take from the provided list, then refilling it once it's empty. This keeps some variety while preventing the risk of repeat sounds

Oh and I added some new signals. Some misc ones, for force say and a different kind of help then the existing one, which I renamed. One for breathing, which I used to clean up leroxin. I was planning to hook this but didn't need to in the end.

One for vomiting too. and eating. Also added a way to update looping timer delays. Forgot about that, I also added variable delay for sound loops, because I thought it sounded better here.

Features audio courtesy of our very own san7890, and the quake jump sound.
  • Loading branch information
LemonInTheDark authored Oct 19, 2022
1 parent 56a8387 commit cd3a778
Show file tree
Hide file tree
Showing 27 changed files with 484 additions and 24 deletions.
23 changes: 20 additions & 3 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_carbon.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
///Called from /datum/species/proc/help : (mob/living/carbon/human/helper, datum/martial_art/helper_style)
#define COMSIG_CARBON_PRE_HELP "carbon_pre_help"
/// Stops the rest of the help
#define COMPONENT_BLOCK_HELP_ACT (1<<0)

///Called from /mob/living/carbon/help_shake_act, before any hugs have ocurred. (mob/living/helper)
#define COMSIG_CARBON_PRE_HELP_ACT "carbon_pre_help"
#define COMSIG_CARBON_PRE_MISC_HELP "carbon_pre_misc_help"
/// Stops the rest of help act (hugging, etc) from occuring
#define COMPONENT_BLOCK_HELP_ACT (1<<0)
#define COMPONENT_BLOCK_MISC_HELP (1<<0)

///Called from /mob/living/carbon/help_shake_act on the person being helped, after any hugs have ocurred. (mob/living/helper)
#define COMSIG_CARBON_HELP_ACT "carbon_help"
Expand Down Expand Up @@ -84,10 +89,20 @@
#define COMPONENT_OVERRIDE_HEALTH_HUD (1<<0)
///Called when a carbon updates their sanity (source = carbon)
#define COMSIG_CARBON_SANITY_UPDATE "carbon_sanity_update"
///Called when a carbon attempts to breath, before the breath has actually occured
#define COMSIG_CARBON_ATTEMPT_BREATHE "carbon_attempt_breathe"
// Prevents the breath
#define COMSIG_CARBON_BLOCK_BREATH (1 << 0)
///Called when a carbon breathes, before the breath has actually occured
#define COMSIG_CARBON_PRE_BREATHE "carbon_pre_breathe"
///Called when a carbon updates their mood
#define COMSIG_CARBON_MOOD_UPDATE "carbon_mood_update"
///Called when a carbon attempts to eat (eating)
#define COMSIG_CARBON_ATTEMPT_EAT "carbon_attempt_eat"
// Prevents the breath
#define COMSIG_CARBON_BLOCK_EAT (1 << 0)
///Called when a carbon vomits : (distance, force)
#define COMSIG_CARBON_VOMITED "carbon_vomited"

// /mob/living/carbon/human signals

Expand All @@ -103,9 +118,11 @@
#define COMSIG_HUMAN_EARLY_UNARMED_ATTACK "human_early_unarmed_attack"
///from mob/living/carbon/human/UnarmedAttack(): (atom/target, proximity, modifiers)
#define COMSIG_HUMAN_MELEE_UNARMED_ATTACK "human_melee_unarmed_attack"
//from /mob/living/carbon/human/proc/check_shields(): (atom/hit_by, damage, attack_text, attack_type, armour_penetration)
///from /mob/living/carbon/human/proc/check_shields(): (atom/hit_by, damage, attack_text, attack_type, armour_penetration)
#define COMSIG_HUMAN_CHECK_SHIELDS "human_check_shields"
#define SHIELD_BLOCK (1<<0)
///from /mob/living/carbon/human/proc/force_say(): ()
#define COMSIG_HUMAN_FORCESAY "human_forcesay"

// Mob transformation signals
///Called when a human turns into a monkey, from /mob/living/carbon/proc/finish_monkeyize()
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define ITEM_SCALING_TRAIT "item_scaling"
/// Trait given by Objects that provide blindsight
#define ITEM_BLIND_TRAIT "blind_item_trait"
/// Trait given by choking
#define CHOKING_TRAIT "choking_trait"
/// Trait given by hallucinations
#define HALLUCINATION_TRAIT "hallucination_trait"

Expand Down
26 changes: 26 additions & 0 deletions code/controllers/subsystem/timer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,32 @@ SUBSYSTEM_DEF(timer)
return null
return timer.timeToRun - (timer.flags & TIMER_CLIENT_TIME ? REALTIMEOFDAY : world.time)

/**
* Update the delay on an existing LOOPING timer
* Will come into effect on the next process
*
* Arguments:
* * id a timerid or a /datum/timedevent
* * new_wait the new wait to give this looping timer
*/
/proc/updatetimedelay(id, new_wait, datum/controller/subsystem/timer/timer_subsystem)
if (!id)
return
if (id == TIMER_ID_NULL)
CRASH("Tried to update the wait of null timerid. Use TIMER_STOPPABLE flag")
if (istype(id, /datum/timedevent))
var/datum/timedevent/timer = id
timer.wait = new_wait
return
timer_subsystem = timer_subsystem || SStimer
//id is string
var/datum/timedevent/timer = timer_subsystem.timer_id_dict[id]
if(!timer || timer.spent)
return
if(!(timer.flags & TIMER_LOOP))
CRASH("Tried to update the wait of a non looping timer. This is not supported")
timer.wait = new_wait

#undef BUCKET_LEN
#undef BUCKET_POS
#undef TIMER_MAX
Expand Down
2 changes: 2 additions & 0 deletions code/datums/components/food/edible.dm
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ Behavior that's still missing from this component that original food items had t
var/who = (isnull(feeder) || eater == feeder) ? "your" : "[eater.p_their()]"
to_chat(feeder, span_warning("You have to remove [who] [covered] first!"))
return FALSE
if(SEND_SIGNAL(eater, COMSIG_CARBON_ATTEMPT_EAT, parent) & COMSIG_CARBON_BLOCK_EAT)
return
return TRUE

///Check foodtypes to see if we should send a moodlet
Expand Down
62 changes: 53 additions & 9 deletions code/datums/looping_sounds/_looping_sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
* A datum for sounds that need to loop, with a high amount of configurability.
*/
/datum/looping_sound
/// The source of the sound, or the recipient of the sound.
var/atom/parent
/// (list or soundfile) Since this can be either a list or a single soundfile you can have random sounds. May contain further lists but must contain a soundfile at the end.
var/mid_sounds
/// The length of time to wait between playing mid_sounds.
var/mid_length
/// Amount of time to add/take away from the mid length, randomly
var/mid_length_vary = 0
/// If we should always play each sound once per loop of all sounds. Weights here only really effect order, and could be disgarded
var/each_once = FALSE
/// Override for volume of start sound.
var/start_volume
/// (soundfile) Played before starting the mid_sounds loop.
Expand All @@ -26,26 +28,34 @@
var/vary = FALSE
/// The max amount of loops to run for.
var/max_loops
/// If true, plays directly to provided atoms instead of from them.
var/direct
/// The extra range of the sound in tiles, defaults to 0.
var/extra_range = 0
/// The ID of the timer that's used to loop the sounds.
var/timer_id
/// How much the sound will be affected by falloff per tile.
var/falloff_exponent
/// The falloff distance of the sound,
var/falloff_distance
/// Do we skip the starting sounds?
var/skip_starting_sounds = FALSE
/// Are the sounds affected by pressure? Defaults to TRUE.
var/pressure_affected = TRUE
/// Are the sounds subject to reverb? Defaults to TRUE.
var/use_reverb = TRUE
/// Are we ignoring walls? Defaults to TRUE.
var/ignore_walls = TRUE

// State stuff
/// The source of the sound, or the recipient of the sound.
var/atom/parent
/// The ID of the timer that's used to loop the sounds.
var/timer_id
/// Has the looping started yet?
var/loop_started = FALSE
/// If we're using cut_mid, this is the list we cut from
var/list/cut_list

// Args
/// Do we skip the starting sounds?
var/skip_starting_sounds = FALSE
/// If true, plays directly to provided atoms instead of from them.
var/direct

/datum/looping_sound/New(_parent, start_immediately = FALSE, _direct = FALSE, _skip_starting_sounds = FALSE)
if(!mid_sounds)
Expand Down Expand Up @@ -108,6 +118,9 @@
if(max_loops && world.time >= start_time + mid_length * max_loops)
stop()
return
// If we have a timer, we're varying mid length, and this is happening while we're runnin mid_sounds
if(timer_id && mid_length_vary && start_time)
updatetimedelay(timer_id, mid_length + rand(-mid_length_vary, mid_length_vary))
if(!chance || prob(chance))
play(get_sound())

Expand Down Expand Up @@ -140,10 +153,41 @@

/// Returns the sound we should now be playing.
/datum/looping_sound/proc/get_sound(_mid_sounds)
. = _mid_sounds || mid_sounds
var/list/play_from = _mid_sounds || mid_sounds
if(!each_once)
. = play_from
while(!isfile(.) && !isnull(.))
. = pick_weight(.)
return .


if(!length(cut_list))
cut_list = shuffle(play_from.Copy())
var/list/tree = list()
. = cut_list
while(!isfile(.) && !isnull(.))
// Tree is a list of lists containign files
// If an entry in the tree goes to 0 length, we cut it from the list
tree += list(.)
. = pick_weight(.)

if(!isfile(.))
return

// Remove the sound file
tree[length(tree)] -= .

// Walk the tree bottom up, remove any lists that are empty
// Don't do anything for the topmost list, cause we do not care
for(var/i in length(tree) to 2 step -1)
var/list/branch = tree[i]
if(length(branch))
break
tree[i - 1] -= list(branch) // Remove the empty list
return .



/// A proc that's there to handle delaying the main sounds if there's a start_sound, and simply starting the sound loop in general.
/datum/looping_sound/proc/on_start()
var/start_wait = 0
Expand Down
12 changes: 12 additions & 0 deletions code/datums/looping_sounds/choking.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/datum/looping_sound/choking
mid_sounds = list('sound/creatures/gag1.ogg' = 1, 'sound/creatures/gag2.ogg' = 1, 'sound/creatures/gag3.ogg' = 1, 'sound/creatures/gag4.ogg' = 1, 'sound/creatures/gag5.ogg' = 1)
mid_length = 1.6 SECONDS
mid_length_vary = 0.3 SECONDS
each_once = TRUE
volume = 90
// We want you to be hard to hear far away
falloff_exponent = 12
pressure_affected = TRUE
vary = TRUE
// Same as above
ignore_walls = FALSE
4 changes: 4 additions & 0 deletions code/datums/mood_events/generic_negative_events.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@
description = "I'm nervous and on edge and I can't stand still!!"
mood_change = -2

/datum/mood_event/choke
description = "I CAN'T BREATHE!!!"
mood_change = -10

/datum/mood_event/vomit
description = "I just threw up. Gross."
mood_change = -2
Expand Down
Loading

0 comments on commit cd3a778

Please sign in to comment.