From ec70d130564c15ccfa7a37fff56551d70c9d388a Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Thu, 30 Jan 2014 15:45:33 -0800 Subject: [PATCH] SINGULOTH OPTIMIZATIONS - See full commit for details. * qdel() instead of del(), wherever possible. * Optimized gravpull logic * /atom/movables can override canSingulothPull() logic to add gravpull exceptions (unless singuloth is 2fat) * assigned_role energy boosts changed into a switch() statement Conflicts: code/modules/mob/living/carbon/human/human.dm code/modules/mob/mob.dm code/modules/power/singularity/singularity.dm --- code/game/atoms_movable.dm | 9 ++++- code/modules/mob/living/carbon/human/human.dm | 11 +++++ code/modules/power/singularity/singularity.dm | 40 ++++++++++++------- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 65c14ffd4fa..72b6e54bf62 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -183,4 +183,11 @@ /atom/movable/overlay/attack_hand(a, b, c) if (src.master) return src.master.attack_hand(a, b, c) - return \ No newline at end of file + return + +///////////////////////////// +// SINGULOTH PULL REFACTOR +///////////////////////////// +/atom/movable/proc/canSingulothPull(var/obj/machinery/singularity/singulo) + return 1 + diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 00b1a4c3955..736770a9788 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1458,3 +1458,14 @@ mob/living/carbon/human/yank_out_object() drop_from_inventory(head) update_hair() update_body() + +/mob/living/carbon/human/canSingulothPull(var/obj/machinery/singularity/singulo) + if(!..()) + return 0 + + if(istype(shoes,/obj/item/clothing/shoes/magboots)) + var/obj/item/clothing/shoes/magboots/M = shoes + if(M.magpulse) + return 0 + return 1 + diff --git a/code/modules/power/singularity/singularity.dm b/code/modules/power/singularity/singularity.dm index 181cc509cb5..e1c9180561d 100644 --- a/code/modules/power/singularity/singularity.dm +++ b/code/modules/power/singularity/singularity.dm @@ -214,7 +214,10 @@ var/global/list/uneatable = list( // Movable atoms only if(dist > consume_range && istype(X, /atom/movable)) if(is_type_in_list(X, uneatable)) continue - if(((X) &&(!X:anchored) && (!istype(X,/mob/living/carbon/human)))|| (src.current_size >= 9)) + if(canPull(X)) + step_towards(X,src) + /* + if((X &&!X:anchored && !istype(X,/mob/living/carbon/human))|| (src.current_size >= 9)) step_towards(X,src) else if(istype(X,/mob/living/carbon/human)) var/mob/living/carbon/human/H = X @@ -223,6 +226,7 @@ var/global/list/uneatable = list( if(M.magpulse) continue step_towards(H,src) + */ // Turf and movable atoms else if(dist <= consume_range && (isturf(X) || istype(X, /atom/movable))) consume(X) @@ -231,6 +235,18 @@ var/global/list/uneatable = list( defer_powernet_rebuild = 0 return +// Singulo optimization: +// Jump out whenever we've made a decision. +/obj/machinery/singularity/proc/canPull(var/atom/movable/A) + // If we're big enough, stop checking for this and that and JUST EAT. + if(current_size >= 9) + return 1 + else + if(A && !A:anchored) + if(A.canSingulothPull(src)) + return 1 + return 0 + /obj/machinery/singularity/proc/consume(var/atom/A) var/gain = 0 @@ -241,15 +257,14 @@ var/global/list/uneatable = list( if(istype(A,/mob/living/carbon/human)) var/mob/living/carbon/human/H = A if(H.mind) - - if((H.mind.assigned_role == "Station Engineer") || (H.mind.assigned_role == "Chief Engineer") ) - gain = 100 - - if(H.mind.assigned_role == "Clown") - gain = rand(-300, 300) // HONK - + switch(H.mind.assigned_role) + if("Station Engineer","Chief Engineer") + gain = 100 + if("Clown") + gain = rand(-300, 300) // HONK spawn() A:gib() + // Why sleep(1) else if(istype(A,/obj/)) @@ -257,7 +272,6 @@ var/global/list/uneatable = list( var/dist = max((current_size - 2),1) explosion(src.loc,(dist),(dist*2),(dist*4)) return - if(istype(A, /obj/machinery/singularity))//Welp now you did it var/obj/machinery/singularity/S = A src.energy += (S.energy/2)//Absorb most of it @@ -267,13 +281,11 @@ var/global/list/uneatable = list( return//Quits here, the obj should be gone, hell we might be if((teleport_del) && (!istype(A, /obj/machinery)))//Going to see if it does not lag less to tele items over to Z 2 - var/obj/O = A - O.x = 2 - O.y = 2 - O.z = 2 + qdel(A) else A.ex_act(1.0) - if(A) del(A) + if(A) + qdel(A) gain = 2 else if(isturf(A)) var/turf/T = A