Vent Clog and False Alarm events: Attempt 2 (#850)

New PR to fix merge issues

Porting an event from tg. Scrubbers get clogged and eject some chemical smoke with potentially fun effeects

I looked through chemsmoke code while doing this, and found it wanting, so i improved it. Added a duration input, adjusted all uses of chemsmoke in the code. Generally gave them all higher durations, chemsmoke grenades were a disappointing poot

Adds a new mundane event, false alarm.
It picks a random moderate or severe event and fakes its announcement without actually running the event.

Three minutes later, CC sends another announcement apologising for the false alarm

Also added an event var allowing events to exclude themselves from being picked for faking
This commit is contained in:
NanakoAC
2016-09-01 19:46:32 +01:00
committed by skull132
parent 893398104f
commit 0b2732b7a0
11 changed files with 158 additions and 22 deletions

View File

@@ -1024,6 +1024,7 @@
#include "code\modules\events\event_container.dm"
#include "code\modules\events\event_dynamic.dm"
#include "code\modules\events\event_manager.dm"
#include "code\modules\events\false_alarm.dm"
#include "code\modules\events\gravity.dm"
#include "code\modules\events\grid_check.dm"
#include "code\modules\events\infestation.dm"
@@ -1040,6 +1041,7 @@
#include "code\modules\events\spacevine.dm"
#include "code\modules\events\spider_infestation.dm"
#include "code\modules\events\spontaneous_appendicitis.dm"
#include "code\modules\events\vent_clog.dm"
#include "code\modules\events\viral_infection.dm"
#include "code\modules\events\wallrot.dm"
#include "code\modules\examine\examine.dm"

View File

@@ -12,18 +12,18 @@
/obj/effect/effect/smoke/chem/New(var/newloc, smoke_duration, turf/dest_turf = null, icon/cached_icon = null)
time_to_live = smoke_duration
..()
create_reagents(500)
if(cached_icon)
icon = cached_icon
set_dir(pick(cardinal))
pixel_x = -32 + rand(-8, 8)
pixel_y = -32 + rand(-8, 8)
//switching opacity on after the smoke has spawned, and then turning it off before it is deleted results in cleaner
//lighting and view range updates (Is this still true with the new lighting system?)
opacity = 1
@@ -64,7 +64,7 @@
// Fades out the smoke smoothly using it's alpha variable.
/obj/effect/effect/smoke/chem/proc/fadeOut(var/frames = 16)
if(!alpha) return //already transparent
frames = max(frames, 1) //We will just assume that by 0 frames, the coder meant "during one frame".
var/alpha_step = round(alpha / frames)
while(alpha > 0)
@@ -82,6 +82,7 @@
var/list/wallList
var/density
var/show_log = 1
var/duration = 20//time smoke lasts, in deciseconds
/datum/effect/effect/system/smoke_spread/chem/spores
show_log = 0
@@ -103,9 +104,10 @@
// Calculates the max range smoke can travel, then gets all turfs in that view range.
// Culls the selected turfs to a (roughly) circle shape, then calls smokeFlow() to make
// sure the smoke can actually path to the turfs. This culls any turfs it can't reach.
/datum/effect/effect/system/smoke_spread/chem/set_up(var/datum/reagents/carry = null, n = 10, c = 0, loca, direct)
/datum/effect/effect/system/smoke_spread/chem/set_up(var/datum/reagents/carry = null, n = 10, c = 0, loca, var/new_duration = 20 )
range = n * 0.3
cardinals = c
duration = new_duration
carry.trans_to_obj(chemholder, carry.total_volume, copy = 1)
if(istype(loca, /turf/))
@@ -178,12 +180,11 @@
I = icon('icons/effects/96x96.dmi', "smoke")
//Calculate smoke duration
var/smoke_duration = 150
var/pressure = 0
var/datum/gas_mixture/environment = location.return_air()
if(environment) pressure = environment.return_pressure()
smoke_duration = between(5, smoke_duration*pressure/(ONE_ATMOSPHERE/3), smoke_duration)
duration = between(5, (duration*pressure)/(ONE_ATMOSPHERE), duration*2)
var/const/arcLength = 2.3559 //distance between each smoke cloud
@@ -191,7 +192,7 @@
var/radius = i * 1.5
if(!radius)
spawn(0)
spawnSmoke(location, I, 1, 1)
spawnSmoke(location, I, duration, 1)
continue
var/offset = 0
@@ -210,7 +211,7 @@
continue
if(T in targetTurfs)
spawn(0)
spawnSmoke(T, I, range)
spawnSmoke(T, I, duration)
//------------------------------------------
// Randomizes and spawns the smoke effect.
@@ -222,7 +223,7 @@
if(passed_smoke)
smoke = passed_smoke
else
smoke = PoolOrNew(/obj/effect/effect/smoke/chem, list(location, smoke_duration + rand(0, 20), T, I))
smoke = PoolOrNew(/obj/effect/effect/smoke/chem, list(location, smoke_duration + rand(smoke_duration*-0.25, smoke_duration*0.25), T, I))
if(chemholder.reagents.reagent_list.len)
chemholder.reagents.trans_to_obj(smoke, chemholder.reagents.total_volume / dist, copy = 1) //copy reagents to the smoke so mob/breathe() can handle inhaling the reagents

View File

@@ -897,7 +897,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
if(i>=25 && i<=40) //Smoke
var/datum/effect/effect/system/smoke_spread/chem/S = new /datum/effect/effect/system/smoke_spread/chem
S.attach(P.loc)
S.set_up(P, 10, 0, P.loc)
S.set_up(P, 10, 0, P.loc, 60)
playsound(P.loc, 'sound/effects/smoke.ogg', 50, 1, -3)
S.start()
message += "Large clouds of smoke billow forth from your [P]!"

View File

@@ -49,6 +49,11 @@
var/endedAt = 0 //When this event ended.
var/datum/event_meta/event_meta = null
var/no_fake = 0
//If set to 1, this event will not be picked for false announcements
//This should really only be used for events that have no announcement
/datum/event/nothing
//Called first before processing.
@@ -114,12 +119,13 @@
activeFor++
//Called when start(), announce() and end() has all been called.
/datum/event/proc/kill()
/datum/event/proc/kill(var/do_end = 1)
// If this event was forcefully killed run end() for individual cleanup
if(isRunning)
isRunning = 0
if(do_end && isRunning)
end()
isRunning = 0
endedAt = world.time
event_manager.active_events -= src
event_manager.event_complete(src)
@@ -137,3 +143,4 @@
setup()
..()

View File

@@ -132,15 +132,17 @@ var/global/list/severity_to_string = list(EVENT_LEVEL_MUNDANE = "Mundane", EVENT
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Brand Intelligence",/datum/event/brand_intelligence,15, list(ASSIGNMENT_JANITOR = 20), 1),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Camera Damage", /datum/event/camera_damage, 20, list(ASSIGNMENT_ENGINEER = 10)),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Economic News", /datum/event/economic_event, 300),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Lost Carp", /datum/event/carp_migration, 20, list(ASSIGNMENT_SECURITY = 10), 1),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Lost Carp", /datum/event/carp_migration, 20, list(ASSIGNMENT_SECURITY = 10), 1),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Money Hacker", /datum/event/money_hacker, 10),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Money Lotto", /datum/event/money_lotto, 0, list(ASSIGNMENT_ANY = 1), 1, 5, 15),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Money Lotto", /datum/event/money_lotto, 0, list(ASSIGNMENT_ANY = 1), 1, 5, 15),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Mundane News", /datum/event/mundane_news, 300),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "PDA Spam", /datum/event/pda_spam, 0, list(ASSIGNMENT_ANY = 3), 0, 0, 50),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Space Dust", /datum/event/dust , 30, list(ASSIGNMENT_ENGINEER = 5), 0, 0, 50),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "PDA Spam", /datum/event/pda_spam, 0, list(ASSIGNMENT_ANY = 3), 0, 0, 50),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Space Dust", /datum/event/dust , 30, list(ASSIGNMENT_ENGINEER = 5), 0, 0, 50),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Trivial News", /datum/event/trivial_news, 400),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Vermin Infestation",/datum/event/infestation, 60, list(ASSIGNMENT_JANITOR = 20, ASSIGNMENT_SECURITY = 10)),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Wallrot", /datum/event/wallrot, 75, list(ASSIGNMENT_ENGINEER = 5, ASSIGNMENT_GARDENER = 20)),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "Clogged Vents", /datum/event/vent_clog, 100),
new /datum/event_meta(EVENT_LEVEL_MUNDANE, "False Alarm", /datum/event/false_alarm, 100),
)
/datum/event_container/moderate

View File

@@ -0,0 +1,37 @@
//False Alarm Event
//This picks a random moderate or severe event and fakes its announcement
//without actually running the event
//After roughly 3 minutes, CC sends another announcement apologising for the false alarm
/datum/event/false_alarm
announceWhen = 0
endWhen = 90
var/datum/event_meta/EM
/datum/event/false_alarm/end()
command_announcement.Announce("Error, It appears our previous announcement about a [EM.name] was a sensor glitch. There is no cause for alarm, please return to your stations.", "False Alarm")
/datum/event/false_alarm/announce()
var/datum/event_container/EC
if (prob(50))
EC = event_manager.event_containers[EVENT_LEVEL_MODERATE]
else
EC = event_manager.event_containers[EVENT_LEVEL_MAJOR]
//Don't pick events that are excluded from faking.
EM = pick(EC.available_events)
var/datum/event/E = null
var/fake_allowed = 0
while (!fake_allowed)
if (E)
E.kill(0)
EM = pick(EC.available_events)
E = new EM.event_type(EM)
fake_allowed = !E.no_fake
message_admins("False Alarm: [E]")
E.kill(0)
E.announce()

View File

@@ -1,3 +1,6 @@
/datum/event/spontaneous_appendicitis
no_fake = 1
/datum/event/spontaneous_appendicitis/start()
for(var/mob/living/carbon/human/H in shuffle(living_mob_list)) if(H.client && H.stat != DEAD)
var/foundAlready = 0 //don't infect someone that already has the virus

View File

@@ -0,0 +1,44 @@
/datum/event/vent_clog
announceWhen = 1
startWhen = 5
endWhen = 35
var/interval = 2
var/list/vents = list()
var/list/gunk = list("water","carbon","flour","radium","toxin","cleaner","nutriment",\
"condensedcapsaicin","mindbreaker","lube","plantbgone","banana","space_drugs",\
"holywater","ethanol","hot_coco","sacid", "hyperzine", "ethanol")
/datum/event/vent_clog/setup()
endWhen = rand(25, 100)
for(var/obj/machinery/atmospherics/unary/vent_scrubber/temp_vent in machines)
if(temp_vent.z in config.station_levels)//STATION ZLEVEL
if(temp_vent.network.normal_members.len > 20)
vents += temp_vent
if(!vents.len)
return kill()
/datum/event/vent_clog/tick()
if(activeFor % interval == 0)
var/obj/machinery/atmospherics/unary/vent_scrubber/vent = pick_n_take(vents)
if(vent && vent.loc)
var/datum/reagents/R = new/datum/reagents(50)
R.my_atom = vent
var/chem = pick(gunk)
R.add_reagent(chem, 50)
var/datum/effect/effect/system/smoke_spread/chem/smoke = new
smoke.show_log = 0//This spams admin logs if not disabled.
smoke.set_up(R, 10, 0, vent, 120)
playsound(vent.loc, 'sound/effects/smoke.ogg', 50, 1, -3)
smoke.start()
qdel(R)
/datum/event/vent_clog/announce()
command_announcement.Announce("The scrubbers network is experiencing a backpressure surge. Some ejection of contents may occur.", "Atmospherics alert")

View File

@@ -93,7 +93,7 @@
var/datum/effect/effect/system/smoke_spread/chem/spores/S = new(name)
S.attach(T)
S.set_up(R, round(get_trait(TRAIT_POTENCY)/4), 0, T)
S.set_up(R, round(get_trait(TRAIT_POTENCY)/4), 0, T, 40)
S.start()
// Does brute damage to a target.

View File

@@ -577,7 +577,7 @@
var/location = get_turf(holder.my_atom)
var/datum/effect/effect/system/smoke_spread/chem/S = new /datum/effect/effect/system/smoke_spread/chem
S.attach(location)
S.set_up(holder, created_volume, 0, location)
S.set_up(holder, created_volume, 0, location, 80)
playsound(location, 'sound/effects/smoke.ogg', 50, 1, -3)
spawn(0)
S.start()

View File

@@ -0,0 +1,40 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
#################################
# Your name.
author: Nanako
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "Added a new mundane event involving smoke!"
- tweak: "Smoke created by chemical smoke grenades will now persist much longer"
- rscadd: "Added a very alarming new event."