mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 11:43:31 +00:00
Refactor carp event to optionally use landmarks if present and stop at the edge of space.
This commit is contained in:
@@ -26,15 +26,6 @@
|
|||||||
max_z = max(z, max_z)
|
max_z = max(z, max_z)
|
||||||
return max_z
|
return max_z
|
||||||
|
|
||||||
/proc/living_observers_present(var/list/zlevels)
|
|
||||||
if(LAZYLEN(zlevels))
|
|
||||||
for(var/mob/M in player_list) //if a tree ticks on the empty zlevel does it really tick
|
|
||||||
if(M.stat != DEAD) //(no it doesn't)
|
|
||||||
var/turf/T = get_turf(M)
|
|
||||||
if(T && (T.z in zlevels))
|
|
||||||
return TRUE
|
|
||||||
return FALSE
|
|
||||||
|
|
||||||
/proc/get_area(atom/A)
|
/proc/get_area(atom/A)
|
||||||
if(isarea(A))
|
if(isarea(A))
|
||||||
return A
|
return A
|
||||||
|
|||||||
@@ -23,15 +23,32 @@
|
|||||||
command_announcement.Announce(announcement, "Lifesign Alert")
|
command_announcement.Announce(announcement, "Lifesign Alert")
|
||||||
|
|
||||||
/datum/event/carp_migration/tick()
|
/datum/event/carp_migration/tick()
|
||||||
if(activeFor % 4 != 0)
|
if(activeFor % 5 != 0)
|
||||||
return // Only process every 8 seconds.
|
return // Only process every 10 seconds.
|
||||||
if(count_spawned_carps() < carp_cap && living_observers_present(affecting_z))
|
if(count_spawned_carps() < carp_cap)
|
||||||
spawn_fish(rand(1, severity * 2) - 1, severity, severity * 2)
|
spawn_fish(rand(1, severity * 2) - 1, severity, severity * 2)
|
||||||
|
|
||||||
/datum/event/carp_migration/proc/spawn_fish(var/num_groups, var/group_size_min, var/group_size_max, var/dir)
|
/datum/event/carp_migration/proc/spawn_fish(var/num_groups, var/group_size_min, var/group_size_max, var/dir)
|
||||||
if(isnull(dir))
|
if(isnull(dir))
|
||||||
dir = (victim && prob(80)) ? victim.fore_dir : pick(GLOB.cardinal)
|
dir = (victim && prob(80)) ? victim.fore_dir : pick(GLOB.cardinal)
|
||||||
|
|
||||||
|
// Check if any landmarks exist!
|
||||||
|
var/list/spawn_locations = list()
|
||||||
|
for(var/obj/effect/landmark/C in landmarks_list)
|
||||||
|
if(C.name == "carpspawn" && (C.z in affecting_z))
|
||||||
|
spawn_locations.Add(C.loc)
|
||||||
|
if(spawn_locations.len) // Okay we've got landmarks, lets use those!
|
||||||
|
shuffle_inplace(spawn_locations)
|
||||||
|
num_groups = min(num_groups, spawn_locations.len)
|
||||||
|
var/i = 1
|
||||||
|
while (i <= num_groups)
|
||||||
|
var/group_size = rand(group_size_min, group_size_max)
|
||||||
|
for (var/j = 0, j < group_size, j++)
|
||||||
|
spawn_one_carp(spawn_locations[i])
|
||||||
|
i++
|
||||||
|
return
|
||||||
|
|
||||||
|
// Okay we did *not* have any landmarks, so lets do our best!
|
||||||
var/i = 1
|
var/i = 1
|
||||||
while (i <= num_groups)
|
while (i <= num_groups)
|
||||||
var/Z = pick(affecting_z)
|
var/Z = pick(affecting_z)
|
||||||
@@ -40,12 +57,23 @@
|
|||||||
var/turf/group_center = pick_random_edge_turf(dir, Z, TRANSITIONEDGE + 2)
|
var/turf/group_center = pick_random_edge_turf(dir, Z, TRANSITIONEDGE + 2)
|
||||||
var/list/turfs = getcircle(group_center, 2)
|
var/list/turfs = getcircle(group_center, 2)
|
||||||
for (var/j = 0, j < group_size, j++)
|
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])
|
var/mob/living/simple_mob/animal/M = spawn_one_carp(turfs[(i % turfs.len) + 1])
|
||||||
|
// Ray trace towards middle of the map to find where they can stop just outside of structure/ship.
|
||||||
|
var/turf/target
|
||||||
|
for(var/turf/T in getline(get_turf(M), map_center))
|
||||||
|
if(!T.is_space())
|
||||||
|
break;
|
||||||
|
target = T
|
||||||
|
if(target)
|
||||||
|
M.ai_holder?.give_destination(target) // Ask carp to swim towards the middle of the map
|
||||||
|
i++
|
||||||
|
|
||||||
|
// Spawn a single carp at given location.
|
||||||
|
/datum/event/carp_migration/proc/spawn_one_carp(var/loc)
|
||||||
|
var/mob/living/simple_mob/animal/M = new /mob/living/simple_mob/animal/space/carp/event(loc)
|
||||||
GLOB.destroyed_event.register(M, src, .proc/on_carp_destruction)
|
GLOB.destroyed_event.register(M, src, .proc/on_carp_destruction)
|
||||||
spawned_carp.Add(M)
|
spawned_carp.Add(M)
|
||||||
M.ai_holder?.give_destination(map_center) // Ask carp to swim towards the middle of the map
|
return M
|
||||||
// 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.
|
// Counts living carp spawned by this event.
|
||||||
/datum/event/carp_migration/proc/count_spawned_carps()
|
/datum/event/carp_migration/proc/count_spawned_carps()
|
||||||
|
|||||||
Reference in New Issue
Block a user