From 10cb8a03e0f8ea3f42868607146839bf82a87014 Mon Sep 17 00:00:00 2001 From: XeonMations Date: Sun, 26 May 2024 19:28:47 +0300 Subject: [PATCH 1/8] make the singularity no longer qdel itself when shot --- code/datums/components/singularity.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 16e04e052a3e2..06c47a74f8056 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -161,7 +161,7 @@ consume(source, user) // Will there be an impact? Who knows. Will we see it? No. -/datum/component/singularity/proc/consume_bullets(obj/projectile/projectile) +/datum/component/singularity/proc/consume_bullets(datum/source, obj/projectile/projectile) SIGNAL_HANDLER qdel(projectile) From 861c60bb234fc84d278b6ecd32125db13c34c542 Mon Sep 17 00:00:00 2001 From: XeonMations Date: Mon, 27 May 2024 12:05:42 +0300 Subject: [PATCH 2/8] singularity movement --- code/datums/components/singularity.dm | 37 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 06c47a74f8056..7aa72be3e6688 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -4,6 +4,9 @@ /// What's the chance that, when a singularity moves, it'll go to its target? #define CHANCE_TO_MOVE_TO_TARGET 60 +//What's the range for the singularity to see things to eat? +#define SINGULARITY_SIGHT_SIZE 10 + /// Things that maybe move around and does stuff to things around them /// Used for the singularity (duh) and Nar'Sie /datum/component/singularity @@ -18,9 +21,12 @@ /// Does this singularity move? var/roaming - /// The chosen direction to drift in + /// The chosen directions to drift in var/drifting_dir + /// The final chosen direction to go. + var/final_dir + /// How many tiles out to pull in var/grav_pull @@ -138,7 +144,7 @@ if(time_since_last_eat > 1) // Delta time is in seconds for "reasons" time_since_last_eat = 0 if (roaming) - move() + move(delta_time) eat() /datum/component/singularity/proc/block_blob() @@ -203,13 +209,26 @@ turfs_to_eat-- -/datum/component/singularity/proc/move() - var/drifting_dir = pick(GLOB.alldirs - last_failed_movement) - - if(!QDELETED(target) && prob(CHANCE_TO_MOVE_TO_TARGET)) - drifting_dir = get_dir(parent, target) - - step(parent, drifting_dir) +/datum/component/singularity/proc/move(delta_time) + var/list/drifting_dir = GLOB.alldirs + drifting_dir -= last_failed_movement + var/neareest_distance = SINGULARITY_SIGHT_SIZE + var/closest_target + var/static/things_to_eat = typecacheof(list(/turf/open/floor, /turf/closed/wall, /obj/structure)) + for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE, parent)) //Find the furthest wall, floor or structure that we can eat, then go that direction + if(A.type in things_to_eat) + var/dist = get_dist(parent, A) + if(dist < neareest_distance) + closest_target = A + neareest_distance = dist + var/dir = get_dir(parent, closest_target) + if(dir in drifting_dir) //Can we go that direction? + final_dir = dir //If so, go that way. + else + final_dir = pick(drifting_dir) //Else, pick a random other direction to go. + if(!QDELETED(target) && prob(CHANCE_TO_MOVE_TO_TARGET)) //Do we have a beacon to go to? If so, with chance, go there instead. + final_dir = get_dir(parent, target) + step(parent, final_dir) /datum/component/singularity/proc/moved(datum/source, atom/new_location) SIGNAL_HANDLER From 0cd2036ae03c2eee570a49c3d21babc4d5d179c2 Mon Sep 17 00:00:00 2001 From: XeonMations Date: Mon, 27 May 2024 19:46:48 +0300 Subject: [PATCH 3/8] fixed --- code/datums/components/singularity.dm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 7aa72be3e6688..1b7379dd70edf 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -5,7 +5,7 @@ #define CHANCE_TO_MOVE_TO_TARGET 60 //What's the range for the singularity to see things to eat? -#define SINGULARITY_SIGHT_SIZE 10 +#define SINGULARITY_SIGHT_SIZE 20 /// Things that maybe move around and does stuff to things around them /// Used for the singularity (duh) and Nar'Sie @@ -212,16 +212,22 @@ /datum/component/singularity/proc/move(delta_time) var/list/drifting_dir = GLOB.alldirs drifting_dir -= last_failed_movement - var/neareest_distance = SINGULARITY_SIGHT_SIZE + var/singularity_sight_modifier + var/nearest_distance = SINGULARITY_SIGHT_SIZE + singularity_sight_modifier var/closest_target - var/static/things_to_eat = typecacheof(list(/turf/open/floor, /turf/closed/wall, /obj/structure)) - for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE, parent)) //Find the furthest wall, floor or structure that we can eat, then go that direction - if(A.type in things_to_eat) + var/static/things_to_eat = typecacheof(list(/turf/closed/wall, /obj/structure, /mob/living)) + var/static/things_to_not_eat = typecacheof(list(/obj/structure/grille/indestructable, /obj/structure/window/reinforced/fulltile/indestructable, /turf/closed/indestructible, /turf/open/indestructible)) + for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE + singularity_sight_modifier, parent)) //Find the nearest wall, floor, structure or mob + if((A.type in things_to_eat) && !(A.type in things_to_not_eat)) //can we eat it? var/dist = get_dist(parent, A) - if(dist < neareest_distance) + if(dist < nearest_distance) closest_target = A - neareest_distance = dist - var/dir = get_dir(parent, closest_target) + nearest_distance = dist + singularity_sight_modifier = 0 + var/dir = get_dir(parent, closest_target) //go that way + if ((dir == null) && (singularity_sight_modifier < 45)) //Increase the search radius if you find nothing, up to a maximum, ofcourse. + singularity_sight_modifier++ + return if(dir in drifting_dir) //Can we go that direction? final_dir = dir //If so, go that way. else From 12a7cb5f786fab73059141644e0cd3f119eae6be Mon Sep 17 00:00:00 2001 From: XeonMations Date: Mon, 27 May 2024 20:34:20 +0300 Subject: [PATCH 4/8] comments --- code/datums/components/singularity.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 1b7379dd70edf..f97fa9d1ea324 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -217,10 +217,10 @@ var/closest_target var/static/things_to_eat = typecacheof(list(/turf/closed/wall, /obj/structure, /mob/living)) var/static/things_to_not_eat = typecacheof(list(/obj/structure/grille/indestructable, /obj/structure/window/reinforced/fulltile/indestructable, /turf/closed/indestructible, /turf/open/indestructible)) - for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE + singularity_sight_modifier, parent)) //Find the nearest wall, floor, structure or mob + for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE + singularity_sight_modifier, parent)) //Find the nearest wall, strucutre or mob if((A.type in things_to_eat) && !(A.type in things_to_not_eat)) //can we eat it? - var/dist = get_dist(parent, A) - if(dist < nearest_distance) + var/dist = get_dist(parent, A) //Get the distance to it. + if(dist < nearest_distance) //Is it closer than the previous iteration? closest_target = A nearest_distance = dist singularity_sight_modifier = 0 From a7df08b773f805ad03445d68e66d505941104edc Mon Sep 17 00:00:00 2001 From: XeonMations Date: Wed, 19 Jun 2024 06:42:51 +0300 Subject: [PATCH 5/8] Revert "comments" This reverts commit 12a7cb5f786fab73059141644e0cd3f119eae6be. --- code/datums/components/singularity.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index f97fa9d1ea324..1b7379dd70edf 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -217,10 +217,10 @@ var/closest_target var/static/things_to_eat = typecacheof(list(/turf/closed/wall, /obj/structure, /mob/living)) var/static/things_to_not_eat = typecacheof(list(/obj/structure/grille/indestructable, /obj/structure/window/reinforced/fulltile/indestructable, /turf/closed/indestructible, /turf/open/indestructible)) - for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE + singularity_sight_modifier, parent)) //Find the nearest wall, strucutre or mob + for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE + singularity_sight_modifier, parent)) //Find the nearest wall, floor, structure or mob if((A.type in things_to_eat) && !(A.type in things_to_not_eat)) //can we eat it? - var/dist = get_dist(parent, A) //Get the distance to it. - if(dist < nearest_distance) //Is it closer than the previous iteration? + var/dist = get_dist(parent, A) + if(dist < nearest_distance) closest_target = A nearest_distance = dist singularity_sight_modifier = 0 From 38c07a84e89de64efc40789b105280b51d02e4dc Mon Sep 17 00:00:00 2001 From: XeonMations Date: Wed, 19 Jun 2024 06:43:00 +0300 Subject: [PATCH 6/8] Revert "fixed" This reverts commit 0cd2036ae03c2eee570a49c3d21babc4d5d179c2. --- code/datums/components/singularity.dm | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 1b7379dd70edf..7aa72be3e6688 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -5,7 +5,7 @@ #define CHANCE_TO_MOVE_TO_TARGET 60 //What's the range for the singularity to see things to eat? -#define SINGULARITY_SIGHT_SIZE 20 +#define SINGULARITY_SIGHT_SIZE 10 /// Things that maybe move around and does stuff to things around them /// Used for the singularity (duh) and Nar'Sie @@ -212,22 +212,16 @@ /datum/component/singularity/proc/move(delta_time) var/list/drifting_dir = GLOB.alldirs drifting_dir -= last_failed_movement - var/singularity_sight_modifier - var/nearest_distance = SINGULARITY_SIGHT_SIZE + singularity_sight_modifier + var/neareest_distance = SINGULARITY_SIGHT_SIZE var/closest_target - var/static/things_to_eat = typecacheof(list(/turf/closed/wall, /obj/structure, /mob/living)) - var/static/things_to_not_eat = typecacheof(list(/obj/structure/grille/indestructable, /obj/structure/window/reinforced/fulltile/indestructable, /turf/closed/indestructible, /turf/open/indestructible)) - for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE + singularity_sight_modifier, parent)) //Find the nearest wall, floor, structure or mob - if((A.type in things_to_eat) && !(A.type in things_to_not_eat)) //can we eat it? + var/static/things_to_eat = typecacheof(list(/turf/open/floor, /turf/closed/wall, /obj/structure)) + for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE, parent)) //Find the furthest wall, floor or structure that we can eat, then go that direction + if(A.type in things_to_eat) var/dist = get_dist(parent, A) - if(dist < nearest_distance) + if(dist < neareest_distance) closest_target = A - nearest_distance = dist - singularity_sight_modifier = 0 - var/dir = get_dir(parent, closest_target) //go that way - if ((dir == null) && (singularity_sight_modifier < 45)) //Increase the search radius if you find nothing, up to a maximum, ofcourse. - singularity_sight_modifier++ - return + neareest_distance = dist + var/dir = get_dir(parent, closest_target) if(dir in drifting_dir) //Can we go that direction? final_dir = dir //If so, go that way. else From dd53aa39b73f585e74dc0d394d9eee184d6e30d4 Mon Sep 17 00:00:00 2001 From: XeonMations Date: Wed, 19 Jun 2024 06:44:42 +0300 Subject: [PATCH 7/8] Update singularity.dm --- code/datums/components/singularity.dm | 34 +++++++-------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 7aa72be3e6688..15a4b2a6c39d7 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -4,9 +4,6 @@ /// What's the chance that, when a singularity moves, it'll go to its target? #define CHANCE_TO_MOVE_TO_TARGET 60 -//What's the range for the singularity to see things to eat? -#define SINGULARITY_SIGHT_SIZE 10 - /// Things that maybe move around and does stuff to things around them /// Used for the singularity (duh) and Nar'Sie /datum/component/singularity @@ -21,7 +18,7 @@ /// Does this singularity move? var/roaming - /// The chosen directions to drift in + /// The chosen direction to drift in var/drifting_dir /// The final chosen direction to go. @@ -144,7 +141,7 @@ if(time_since_last_eat > 1) // Delta time is in seconds for "reasons" time_since_last_eat = 0 if (roaming) - move(delta_time) + move() eat() /datum/component/singularity/proc/block_blob() @@ -209,26 +206,13 @@ turfs_to_eat-- -/datum/component/singularity/proc/move(delta_time) - var/list/drifting_dir = GLOB.alldirs - drifting_dir -= last_failed_movement - var/neareest_distance = SINGULARITY_SIGHT_SIZE - var/closest_target - var/static/things_to_eat = typecacheof(list(/turf/open/floor, /turf/closed/wall, /obj/structure)) - for(var/atom/A as() in oview(SINGULARITY_SIGHT_SIZE, parent)) //Find the furthest wall, floor or structure that we can eat, then go that direction - if(A.type in things_to_eat) - var/dist = get_dist(parent, A) - if(dist < neareest_distance) - closest_target = A - neareest_distance = dist - var/dir = get_dir(parent, closest_target) - if(dir in drifting_dir) //Can we go that direction? - final_dir = dir //If so, go that way. - else - final_dir = pick(drifting_dir) //Else, pick a random other direction to go. - if(!QDELETED(target) && prob(CHANCE_TO_MOVE_TO_TARGET)) //Do we have a beacon to go to? If so, with chance, go there instead. - final_dir = get_dir(parent, target) - step(parent, final_dir) +/datum/component/singularity/proc/move() + var/drifting_dir = pick(GLOB.alldirs - last_failed_movement) + + if(!QDELETED(target) && prob(CHANCE_TO_MOVE_TO_TARGET)) + drifting_dir = get_dir(parent, target) + + step(parent, drifting_dir) /datum/component/singularity/proc/moved(datum/source, atom/new_location) SIGNAL_HANDLER From ece1a9e12330d01458b2b541804085f75f5f8581 Mon Sep 17 00:00:00 2001 From: XeonMations Date: Wed, 19 Jun 2024 06:45:05 +0300 Subject: [PATCH 8/8] Update singularity.dm --- code/datums/components/singularity.dm | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/datums/components/singularity.dm b/code/datums/components/singularity.dm index 15a4b2a6c39d7..06c47a74f8056 100644 --- a/code/datums/components/singularity.dm +++ b/code/datums/components/singularity.dm @@ -21,9 +21,6 @@ /// The chosen direction to drift in var/drifting_dir - /// The final chosen direction to go. - var/final_dir - /// How many tiles out to pull in var/grav_pull