mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Ports overmap events from Baystation12
- Move overmap defines to _defines folder. Rename old file to turfs.dm since that is what it contains. - Definition of overmap event objects and the overmap event handler. - Upgrades to SSevents and SSskybox to tie in the overmap events. - Enhancement to /datum/event itself to support affecting_z and victim ship. - Upgrade to the five event types used on the overmap to support new vars. - Upgrade to dust and meteor spawning code to support targeting z-levels.
This commit is contained in:
@@ -1,51 +1,75 @@
|
||||
/datum/event/carp_migration
|
||||
announceWhen = 50
|
||||
endWhen = 900
|
||||
|
||||
startWhen = 0 // Start immediately
|
||||
announceWhen = 45 // Adjusted by setup
|
||||
endWhen = 75 // Adjusted by setup
|
||||
var/carp_cap = 10
|
||||
var/list/spawned_carp = list()
|
||||
|
||||
/datum/event/carp_migration/setup()
|
||||
announceWhen = rand(40, 60)
|
||||
endWhen = rand(600,1200)
|
||||
announceWhen = rand(30, 60) // 1 to 2 minutes
|
||||
endWhen += severity * 25
|
||||
carp_cap = 2 + 3 ** severity // No more than this many at once regardless of waves. (5, 11, 29)
|
||||
|
||||
/datum/event/carp_migration/announce()
|
||||
var/announcement = ""
|
||||
if(severity == EVENT_LEVEL_MAJOR)
|
||||
announcement = "Massive migration of unknown biological entities has been detected near [station_name()], please stand-by."
|
||||
announcement = "Massive migration of unknown biological entities has been detected near [location_name()], please stand-by."
|
||||
else
|
||||
announcement = "Unknown biological [spawned_carp.len == 1 ? "entity has" : "entities have"] been detected near [station_name()], please stand-by."
|
||||
announcement = "Unknown biological [spawned_carp.len == 1 ? "entity has" : "entities have"] been detected near [location_name()], please stand-by."
|
||||
command_announcement.Announce(announcement, "Lifesign Alert")
|
||||
|
||||
/datum/event/carp_migration/start()
|
||||
if(severity == EVENT_LEVEL_MAJOR)
|
||||
spawn_fish(landmarks_list.len)
|
||||
else if(severity == EVENT_LEVEL_MODERATE)
|
||||
spawn_fish(rand(4, 6)) //12 to 30 carp, in small groups
|
||||
else
|
||||
spawn_fish(rand(1, 3), 1, 2) //1 to 6 carp, alone or in pairs
|
||||
/datum/event/carp_migration/tick()
|
||||
if(activeFor % 4 != 0)
|
||||
return // Only process every 8 seconds.
|
||||
if(count_spawned_carps() < carp_cap && living_observers_present(affecting_z))
|
||||
spawn_fish(rand(1, severity * 2) - 1, severity, severity * 2)
|
||||
|
||||
/datum/event/carp_migration/proc/spawn_fish(var/num_groups, var/group_size_min=3, var/group_size_max=5)
|
||||
var/list/spawn_locations = list()
|
||||
|
||||
for(var/obj/effect/landmark/C in landmarks_list)
|
||||
if(C.name == "carpspawn")
|
||||
spawn_locations.Add(C.loc)
|
||||
spawn_locations = shuffle(spawn_locations)
|
||||
num_groups = min(num_groups, spawn_locations.len)
|
||||
/datum/event/carp_migration/proc/spawn_fish(var/num_groups, var/group_size_min, var/group_size_max, var/dir)
|
||||
if(isnull(dir))
|
||||
dir = (victim && prob(80)) ? victim.fore_dir : pick(GLOB.cardinal)
|
||||
|
||||
var/i = 1
|
||||
while (i <= num_groups)
|
||||
var/Z = pick(affecting_z)
|
||||
var/group_size = rand(group_size_min, group_size_max)
|
||||
for (var/j = 1, j <= group_size, j++)
|
||||
spawned_carp.Add(new /mob/living/simple_mob/animal/space/carp/event(spawn_locations[i]))
|
||||
var/turf/map_center = locate(round(world.maxx/2), round(world.maxy/2), Z)
|
||||
var/turf/group_center = pick_random_edge_turf(dir, Z, TRANSITIONEDGE + 2)
|
||||
var/list/turfs = getcircle(group_center, 2)
|
||||
for (var/j = 0, j < group_size, j++)
|
||||
var/mob/living/simple_mob/animal/M = new /mob/living/simple_mob/animal/space/carp/event(turfs[(i % turfs.len) + 1])
|
||||
GLOB.destroyed_event.register(M, src, .proc/on_carp_destruction)
|
||||
spawned_carp.Add(M)
|
||||
M.ai_holder?.give_destination(map_center) // Ask carp to swim towards the middle of the map
|
||||
// TODO - Our throwing systems don't support callbacks. If it ever does, we can throw first to simulate ship speed.
|
||||
i++
|
||||
|
||||
// Counts living carp spawned by this event.
|
||||
/datum/event/carp_migration/proc/count_spawned_carps()
|
||||
. = 0
|
||||
for(var/I in spawned_carp)
|
||||
var/mob/living/simple_mob/animal/M = I
|
||||
if(!QDELETED(M) && M.stat != DEAD)
|
||||
. += 1
|
||||
|
||||
// If carp is bomphed, remove it from the list.
|
||||
/datum/event/carp_migration/proc/on_carp_destruction(var/mob/M)
|
||||
spawned_carp -= M
|
||||
GLOB.destroyed_event.unregister(M, src, .proc/on_carp_destruction)
|
||||
|
||||
/datum/event/carp_migration/end()
|
||||
. = ..()
|
||||
// Clean up carp that died in space for some reason.
|
||||
spawn(0)
|
||||
for(var/mob/living/simple_mob/SM in spawned_carp)
|
||||
if(!SM.stat)
|
||||
if(SM.stat == DEAD)
|
||||
var/turf/T = get_turf(SM)
|
||||
if(istype(T, /turf/space))
|
||||
if(prob(75))
|
||||
qdel(SM)
|
||||
sleep(1)
|
||||
CHECK_TICK
|
||||
|
||||
//
|
||||
// Overmap version of the event!
|
||||
//
|
||||
/datum/event/carp_migration/overmap
|
||||
announceWhen = 1 // Announce much faster!
|
||||
|
||||
@@ -3,13 +3,17 @@
|
||||
endWhen = 30
|
||||
|
||||
/datum/event/dust/announce()
|
||||
command_announcement.Announce("Debris resulting from activity on another nearby asteroid is approaching \the [station_name()]", "Dust Alert")
|
||||
if(victim)
|
||||
command_announcement.Announce("The [location_name()] is now passing through a belt of space dust.", "[location_name()] Sensor Array")
|
||||
else
|
||||
command_announcement.Announce("Debris resulting from activity on another nearby asteroid is approaching \the [location_name()]", "Dust Alert")
|
||||
|
||||
/datum/event/dust/start()
|
||||
dust_swarm(get_severity())
|
||||
/datum/event/dust/tick()
|
||||
if(prob(10))
|
||||
dust_swarm(severity, affecting_z)
|
||||
|
||||
/datum/event/dust/end()
|
||||
command_announcement.Announce("\The [station_name()] is no longer in danger of impact from space debris.", "Dust Notice")
|
||||
command_announcement.Announce("\The [location_name()] is no longer in danger of impact from space debris.", "Dust Notice")
|
||||
|
||||
/datum/event/dust/proc/get_severity()
|
||||
switch(severity)
|
||||
|
||||
@@ -1,28 +1,61 @@
|
||||
/datum/event/electrical_storm
|
||||
var/lightsoutAmount = 1
|
||||
var/lightsoutRange = 25
|
||||
announceWhen = 0 // Warn them shortly before it begins.
|
||||
startWhen = 30 // 1 minute
|
||||
endWhen = 60 // Set in setup()
|
||||
has_skybox_image = TRUE
|
||||
var/tmp/lightning_color
|
||||
var/tmp/list/valid_apcs // List of valid APCs.
|
||||
|
||||
/datum/event/electrical_storm/get_skybox_image()
|
||||
if(!lightning_color)
|
||||
lightning_color = pick("#ffd98c", "#ebc7ff", "#bdfcff", "#bdd2ff", "#b0ffca", "#ff8178", "#ad74cc")
|
||||
var/image/res = image('icons/skybox/electrobox.dmi', "lightning")
|
||||
res.color = lightning_color
|
||||
res.appearance_flags = RESET_COLOR
|
||||
res.blend_mode = BLEND_ADD
|
||||
return res
|
||||
|
||||
/datum/event/electrical_storm/announce()
|
||||
command_announcement.Announce("An electrical issue has been detected in your area, please repair potential electronic overloads.", "Electrical Alert")
|
||||
|
||||
..()
|
||||
switch(severity)
|
||||
if(EVENT_LEVEL_MUNDANE)
|
||||
command_announcement.Announce("A minor electrical storm has been detected near the [location_name()]. Please watch out for possible electrical discharges.", "[location_name()] Sensor Array")
|
||||
if(EVENT_LEVEL_MODERATE)
|
||||
command_announcement.Announce("The [location_name()] is about to pass through an electrical storm. Please secure sensitive electrical equipment until the storm passes.", "[location_name()] Sensor Array")
|
||||
if(EVENT_LEVEL_MAJOR)
|
||||
command_announcement.Announce("Alert. A strong electrical storm has been detected in proximity of the [location_name()]. It is recommended to immediately secure sensitive electrical equipment until the storm passes.", "[location_name()] Sensor Array")
|
||||
|
||||
/datum/event/electrical_storm/start()
|
||||
var/list/epicentreList = list()
|
||||
..()
|
||||
valid_apcs = list()
|
||||
for(var/obj/machinery/power/apc/A in global.machines)
|
||||
if(A.z in affecting_z)
|
||||
valid_apcs.Add(A)
|
||||
endWhen = (severity * 60) + startWhen
|
||||
|
||||
for(var/i=1, i <= lightsoutAmount, i++)
|
||||
var/list/possibleEpicentres = list()
|
||||
for(var/obj/effect/landmark/newEpicentre in landmarks_list)
|
||||
if(newEpicentre.name == "lightsout" && !(newEpicentre in epicentreList))
|
||||
possibleEpicentres += newEpicentre
|
||||
if(possibleEpicentres.len)
|
||||
epicentreList += pick(possibleEpicentres)
|
||||
else
|
||||
break
|
||||
/datum/event/electrical_storm/tick()
|
||||
..()
|
||||
// See if shields can stop it first (It would be nice to port baystation's cooler shield gens perhaps)
|
||||
// TODO - We need a better shield generator system to handle this properly.
|
||||
if(!valid_apcs.len)
|
||||
log_debug("No valid APCs found for electrical storm event ship=[victim]!")
|
||||
return
|
||||
var/list/picked_apcs = list()
|
||||
for(var/i=0, i< severity * 2, i++) // up to 2/4/6 APCs per tick depending on severity
|
||||
picked_apcs |= pick(valid_apcs)
|
||||
for(var/obj/machinery/power/apc/T in picked_apcs)
|
||||
affect_apc(T)
|
||||
|
||||
if(!epicentreList.len)
|
||||
/datum/event/electrical_storm/proc/affect_apc(var/obj/machinery/power/apc/T)
|
||||
// Main breaker is turned off. Consider this APC protected.
|
||||
if(!T.operating)
|
||||
return
|
||||
|
||||
for(var/obj/effect/landmark/epicentre in epicentreList)
|
||||
for(var/obj/machinery/power/apc/apc in range(epicentre,lightsoutRange))
|
||||
apc.overload_lighting()
|
||||
// Decent chance to overload lighting circuit.
|
||||
if(prob(3 * severity))
|
||||
T.overload_lighting()
|
||||
|
||||
// Relatively small chance to emag the apc as apc_damage event does.
|
||||
if(prob(0.2 * severity))
|
||||
T.emagged = 1
|
||||
T.update_icon()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Event Meta instances represent choices for the event manager to choose for random events.
|
||||
/datum/event_meta
|
||||
var/name = ""
|
||||
var/enabled = 1 // Whether or not the event is available for random selection at all
|
||||
@@ -39,6 +40,10 @@
|
||||
|
||||
return total_weight
|
||||
|
||||
/datum/event_meta/no_overmap/get_weight() //these events have overmap equivalents, and shouldn't fire randomly if overmap is used
|
||||
return global.using_map.use_overmap ? 0 : ..()
|
||||
|
||||
// Event datums define and execute the actual events themselves.
|
||||
/datum/event //NOTE: Times are measured in master controller ticks!
|
||||
var/startWhen = 0 //When in the lifetime to call start().
|
||||
var/announceWhen = 0 //When in the lifetime to call announce().
|
||||
@@ -51,6 +56,9 @@
|
||||
var/endedAt = 0 //When this event ended.
|
||||
var/processing_active = TRUE
|
||||
var/datum/event_meta/event_meta = null
|
||||
var/list/affecting_z = null // List of z-levels to affect, null lets the event choose (usally station_levels)
|
||||
var/has_skybox_image = FALSE // True if SSskybox should query this event for an image to put in the skybox.
|
||||
var/obj/effect/overmap/visitable/ship/victim = null // Ship that triggered this event on itself. Some messages might be different etc.
|
||||
|
||||
/datum/event/nothing
|
||||
|
||||
@@ -65,6 +73,8 @@
|
||||
//Allows you to start before announcing or vice versa.
|
||||
//Only called once.
|
||||
/datum/event/proc/start()
|
||||
if(has_skybox_image)
|
||||
SSskybox.rebuild_skyboxes(affecting_z)
|
||||
return
|
||||
|
||||
//Called when the tick is equal to the announceWhen variable.
|
||||
@@ -87,6 +97,8 @@
|
||||
//For example: if(activeFor == myOwnVariable + 30) doStuff()
|
||||
//Only called once.
|
||||
/datum/event/proc/end()
|
||||
if(has_skybox_image)
|
||||
SSskybox.rebuild_skyboxes(affecting_z)
|
||||
return
|
||||
|
||||
//Returns the latest point of event processing.
|
||||
@@ -132,9 +144,12 @@
|
||||
end()
|
||||
|
||||
endedAt = world.time
|
||||
SSevents.active_events -= src
|
||||
SSevents.event_complete(src)
|
||||
|
||||
//Called during building of skybox to get overlays
|
||||
/datum/event/proc/get_skybox_image()
|
||||
return
|
||||
|
||||
/datum/event/New(var/datum/event_meta/EM)
|
||||
// event needs to be responsible for this, as stuff like APLUs currently make their own events for curious reasons
|
||||
SSevents.active_events += src
|
||||
@@ -146,5 +161,17 @@
|
||||
|
||||
startedAt = world.time
|
||||
|
||||
if(!affecting_z)
|
||||
affecting_z = using_map.station_levels
|
||||
|
||||
setup()
|
||||
..()
|
||||
|
||||
/datum/event/Destroy()
|
||||
victim = null
|
||||
. = ..()
|
||||
|
||||
/datum/event/proc/location_name()
|
||||
if(victim)
|
||||
return victim.name
|
||||
return station_name()
|
||||
|
||||
@@ -1,20 +1,51 @@
|
||||
//This file was auto-corrected by findeclaration.exe on 29/05/2012 15:03:04
|
||||
|
||||
/datum/event/ionstorm
|
||||
has_skybox_image = TRUE
|
||||
var/botEmagChance = 0 //VOREStation Edit
|
||||
var/cloud_hueshift
|
||||
var/list/players = list()
|
||||
|
||||
/datum/event/ionstorm/announce()
|
||||
/datum/event/ionstorm/get_skybox_image()
|
||||
if(!cloud_hueshift)
|
||||
cloud_hueshift = color_rotation(rand(-3, 3) * 15)
|
||||
var/image/res = image('icons/skybox/ionbox.dmi', "ions")
|
||||
res.color = cloud_hueshift
|
||||
res.appearance_flags = RESET_COLOR
|
||||
res.blend_mode = BLEND_ADD
|
||||
return res
|
||||
|
||||
/datum/event/ionstorm/setup()
|
||||
endWhen = rand(500, 1500)
|
||||
|
||||
// Interestingly enough, announce() actually *DOES* this event for some reason.
|
||||
/datum/event/ionstorm/announce()
|
||||
// command_alert("The station has entered an ion storm. Monitor all electronic equipment for malfunctions", "Anomaly Alert")
|
||||
for (var/mob/living/carbon/human/player in player_list)
|
||||
if( !player.mind || player_is_antag(player.mind, only_offstation_roles = 1) || player.client.inactivity > MinutesToTicks(10))
|
||||
continue
|
||||
players += player.real_name
|
||||
|
||||
// Flomph synthetics
|
||||
for(var/mob/living/carbon/S in living_mob_list)
|
||||
if (!S.isSynthetic())
|
||||
continue
|
||||
if(!(S.z in affecting_z))
|
||||
continue
|
||||
var/area/A = get_area(S)
|
||||
if(!A || A.flags & RAD_SHIELDED) // Rad shielding will protect from ions too
|
||||
continue
|
||||
to_chat(S, "<span class='warning'>Your integrated sensors detect an ionospheric anomaly. Your systems will be impacted as you begin a partial restart.</span>")
|
||||
var/ionbug = rand(3, 9)
|
||||
S.confused += ionbug
|
||||
S.eye_blurry += (ionbug - 1)
|
||||
|
||||
// Ionize silicon mobs
|
||||
for (var/mob/living/silicon/ai/target in silicon_mob_list)
|
||||
if(!(target.z in affecting_z))
|
||||
continue
|
||||
var/law = target.generate_ion_law()
|
||||
to_chat(target, "<font color='red'><b>You have detected a change in your laws information:</b></font>")
|
||||
to_chat(target, "<span class='danger'>You have detected a change in your laws information:</span>")
|
||||
to_chat(target, law)
|
||||
target.add_ion_law(law)
|
||||
target.show_laws()
|
||||
@@ -31,13 +62,15 @@
|
||||
/datum/event/ionstorm/tick()
|
||||
if(botEmagChance)
|
||||
for(var/mob/living/bot/bot in mob_list)
|
||||
if(!(bot.z in affecting_z))
|
||||
continue
|
||||
if(prob(botEmagChance))
|
||||
bot.emag_act(1)
|
||||
|
||||
/datum/event/ionstorm/end()
|
||||
spawn(rand(5000,8000))
|
||||
if(prob(50))
|
||||
ion_storm_announcement()
|
||||
if(prob(50))
|
||||
spawn(rand(5000,8000))
|
||||
command_announcement.Announce("It has come to our attention that \the [location_name()] passed through an ion storm. Please monitor all electronic equipment for malfunctions.", "Anomaly Alert")
|
||||
|
||||
/*
|
||||
/proc/IonStorm(botEmagChance = 10)
|
||||
|
||||
@@ -1,30 +1,45 @@
|
||||
/datum/event/meteor_wave
|
||||
startWhen = 5
|
||||
endWhen = 7
|
||||
startWhen = 30 // About one minute early warning
|
||||
endWhen = 60 // Adjusted automatically in tick()
|
||||
has_skybox_image = TRUE
|
||||
var/next_meteor = 6
|
||||
var/waves = 1
|
||||
var/start_side
|
||||
var/next_meteor_lower = 10
|
||||
var/next_meteor_upper = 20
|
||||
|
||||
/datum/event/meteor_wave/get_skybox_image()
|
||||
var/image/res = image('icons/skybox/rockbox.dmi', "rockbox")
|
||||
res.color = COLOR_ASTEROID_ROCK
|
||||
res.appearance_flags = RESET_COLOR
|
||||
return res
|
||||
|
||||
/datum/event/meteor_wave/setup()
|
||||
waves = 2 + rand(1, severity) //EVENT_LEVEL_MAJOR is 3-5 waves
|
||||
waves = (2 + rand(1, severity)) * severity
|
||||
start_side = pick(cardinal)
|
||||
endWhen = worst_case_end()
|
||||
|
||||
/datum/event/meteor_wave/announce()
|
||||
switch(severity)
|
||||
if(EVENT_LEVEL_MAJOR)
|
||||
command_announcement.Announce("Meteors have been detected on collision course with \the [station_name()].", "Meteor Alert", new_sound = 'sound/AI/meteors.ogg')
|
||||
command_announcement.Announce("Meteors have been detected on collision course with \the [location_name()].", "Meteor Alert", new_sound = 'sound/AI/meteors.ogg')
|
||||
else
|
||||
command_announcement.Announce("\The [station_name()] is now in a meteor shower.", "Meteor Alert")
|
||||
command_announcement.Announce("\The [location_name()] is now in a meteor shower.", "Meteor Alert")
|
||||
|
||||
/datum/event/meteor_wave/tick()
|
||||
if(waves && activeFor >= next_meteor)
|
||||
var/pick_side = prob(80) ? start_side : (prob(50) ? turn(start_side, 90) : turn(start_side, -90))
|
||||
send_wave()
|
||||
|
||||
spawn() spawn_meteors(severity * rand(1,2), get_meteors(), pick_side)
|
||||
next_meteor += rand(15, 30) / severity
|
||||
waves--
|
||||
endWhen = worst_case_end()
|
||||
/datum/event/meteor_wave/proc/send_wave()
|
||||
var/pick_side = prob(80) ? start_side : (prob(50) ? turn(start_side, 90) : turn(start_side, -90))
|
||||
|
||||
spawn() spawn_meteors(get_wave_size(), get_meteors(), pick_side, pick(affecting_z))
|
||||
next_meteor += rand(next_meteor_lower, next_meteor_upper) / severity
|
||||
waves--
|
||||
endWhen = worst_case_end()
|
||||
|
||||
/datum/event/meteor_wave/proc/get_wave_size()
|
||||
return severity * rand(2, 3)
|
||||
|
||||
/datum/event/meteor_wave/proc/worst_case_end()
|
||||
return activeFor + ((30 / severity) * waves) + 10
|
||||
@@ -32,9 +47,9 @@
|
||||
/datum/event/meteor_wave/end()
|
||||
switch(severity)
|
||||
if(EVENT_LEVEL_MAJOR)
|
||||
command_announcement.Announce("\The [station_name()] has cleared the meteor storm.", "Meteor Alert")
|
||||
command_announcement.Announce("\The [location_name()] has cleared the meteor storm.", "Meteor Alert")
|
||||
else
|
||||
command_announcement.Announce("\The [station_name()] has cleared the meteor shower", "Meteor Alert")
|
||||
command_announcement.Announce("\The [location_name()] has cleared the meteor shower", "Meteor Alert")
|
||||
|
||||
/datum/event/meteor_wave/proc/get_meteors()
|
||||
if(EVENT_LEVEL_MAJOR)
|
||||
@@ -44,3 +59,41 @@
|
||||
return meteors_threatening
|
||||
else
|
||||
return meteors_normal
|
||||
|
||||
|
||||
/datum/event/meteor_wave/overmap
|
||||
next_meteor_lower = 5
|
||||
next_meteor_upper = 10
|
||||
next_meteor = 0
|
||||
|
||||
/datum/event/meteor_wave/overmap/tick()
|
||||
if(victim && !victim.is_still()) // Meteors mostly fly in your face
|
||||
start_side = prob(90) ? victim.fore_dir : pick(GLOB.cardinal)
|
||||
else //Unless you're standing still
|
||||
start_side = pick(GLOB.cardinal)
|
||||
..()
|
||||
|
||||
/datum/event/meteor_wave/overmap/get_wave_size()
|
||||
. = ..()
|
||||
if(!victim)
|
||||
return
|
||||
var/skill = victim.get_helm_skill()
|
||||
var/speed = victim.get_speed()
|
||||
if(skill >= SKILL_PROF)
|
||||
. = round(. * 0.5)
|
||||
if(victim.is_still()) //Standing still means less shit flies your way
|
||||
. = round(. * 0.1)
|
||||
if(speed < SHIP_SPEED_SLOW) //Slow and steady
|
||||
. = round(. * 0.5)
|
||||
if(speed > SHIP_SPEED_FAST) //Sanic stahp
|
||||
. *= 2
|
||||
|
||||
//Smol ship evasion
|
||||
if(victim.vessel_size < SHIP_SIZE_LARGE && speed < SHIP_SPEED_FAST)
|
||||
var/skill_needed = SKILL_PROF
|
||||
if(speed < SHIP_SPEED_SLOW)
|
||||
skill_needed = SKILL_ADEPT
|
||||
if(victim.vessel_size < SHIP_SIZE_SMALL)
|
||||
skill_needed = skill_needed - 1
|
||||
if(skill >= max(skill_needed, victim.skill_needed))
|
||||
. = round(. * 0.5)
|
||||
|
||||
Reference in New Issue
Block a user