mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 02:16:05 +00:00
Singularity less laggy by me.
This commit is contained in:
@@ -17,7 +17,11 @@
|
|||||||
if (isarea(A))
|
if (isarea(A))
|
||||||
return A
|
return A
|
||||||
|
|
||||||
A = A.loc
|
switch (istype(A))
|
||||||
|
if (1)
|
||||||
|
A = A.loc
|
||||||
|
if (0)
|
||||||
|
return
|
||||||
|
|
||||||
/proc/get_area_master(const/O)
|
/proc/get_area_master(const/O)
|
||||||
var/area/A = get_area(O)
|
var/area/A = get_area(O)
|
||||||
|
|||||||
@@ -1256,7 +1256,11 @@ proc/get_mob_with_client_list()
|
|||||||
if (isturf(A))
|
if (isturf(A))
|
||||||
return A
|
return A
|
||||||
|
|
||||||
A = A.loc
|
switch (istype(A))
|
||||||
|
if (1)
|
||||||
|
A = A.loc
|
||||||
|
if (0)
|
||||||
|
return
|
||||||
|
|
||||||
/proc/get(atom/loc, type)
|
/proc/get(atom/loc, type)
|
||||||
while(loc)
|
while(loc)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
// Added spess ghoasts/cameras to this so they don't add to the lag. - N3X
|
// Added spess ghoasts/cameras to this so they don't add to the lag. - N3X
|
||||||
var/global/list/uneatable = list(
|
var/global/list/uneatable = list(
|
||||||
/turf/space,
|
|
||||||
/obj/effect/overlay,
|
/obj/effect/overlay,
|
||||||
/mob/dead,
|
/mob/dead,
|
||||||
/mob/camera,
|
/mob/camera,
|
||||||
@@ -38,7 +37,6 @@ var/global/list/uneatable = list(
|
|||||||
var/event_chance = 15 //Prob for event each tick
|
var/event_chance = 15 //Prob for event each tick
|
||||||
var/target = null //its target. moves towards the target if it has one
|
var/target = null //its target. moves towards the target if it has one
|
||||||
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
|
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
|
||||||
var/teleport_del = 0
|
|
||||||
var/last_warning
|
var/last_warning
|
||||||
|
|
||||||
|
|
||||||
@@ -227,298 +225,91 @@ var/global/list/uneatable = list(
|
|||||||
|
|
||||||
|
|
||||||
/obj/machinery/singularity/proc/eat()
|
/obj/machinery/singularity/proc/eat()
|
||||||
|
set background = BACKGROUND_ENABLED
|
||||||
|
|
||||||
|
if (defer_powernet_rebuild != 2)
|
||||||
|
|
||||||
|
|
||||||
var/countit = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//set background = 1
|
|
||||||
if(defer_powernet_rebuild != 2)
|
|
||||||
defer_powernet_rebuild = 1
|
defer_powernet_rebuild = 1
|
||||||
|
|
||||||
// Let's just make this one loop.
|
for (var/turf/T in trange(grav_pull, src)) // TODO: Create a similar trange for orange to prevent snowflake of self check.
|
||||||
var/atom/X
|
var/dist = get_dist(T, src)
|
||||||
|
|
||||||
for(X in orange(grav_pull, src))
|
for (var/atom/A in T.contents)
|
||||||
// N3X: Move this up here since get_dist is slow.
|
if (is_type_in_list(A, uneatable) || A == src)
|
||||||
if(is_type_in_list(X, uneatable))
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
var/dist = get_dist(X, src)
|
if (dist <= consume_range)
|
||||||
|
consume(A)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if (dist > consume_range)
|
||||||
|
if (101 == A.invisibility)
|
||||||
|
continue
|
||||||
|
|
||||||
|
step_towards(A, src)
|
||||||
|
|
||||||
|
if (!istype(T, /turf/space) && dist <= consume_range)
|
||||||
|
consume(T)
|
||||||
|
|
||||||
|
if (defer_powernet_rebuild != 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Movable atoms only
|
|
||||||
if(dist > consume_range && istype(X, /atom/movable))
|
|
||||||
var/pullable = canPull(X)
|
|
||||||
|
|
||||||
if(pullable)
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////test
|
|
||||||
//world << "<font size='1' color='red'><b>[X.type]/b></font>" //debugging
|
|
||||||
if(istype(X, /mob) && pullable)
|
|
||||||
|
|
||||||
if(pick(0,1))
|
|
||||||
step_towards(X,src)
|
|
||||||
//if(prob(10))
|
|
||||||
// consume(X) //sometimes you get unlucky, gravitation corona effect or some such.......... (apparently players dont want to die, who knew?)
|
|
||||||
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
|
|
||||||
//some sort of event horizon effect yea? it all makes sense.....shhhh....it all makes sense....
|
|
||||||
if((countit <= eatlimit) || current_size == 1)
|
|
||||||
// world << "<font size='1' color='red'><b>Hit here: [countit]</b></font>" //debugging
|
|
||||||
if(pick(0,1))
|
|
||||||
/////////////
|
|
||||||
|
|
||||||
if!((current_size >= 9) && !(pullable))
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
spawn(0)
|
|
||||||
|
|
||||||
var/takeloc = get_turf(X.loc)
|
|
||||||
var/obj/machinery/singularity/takeit = new /atom/movable/overlay( takeloc )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
takeit.icon = 'icons/obj/singularity.dmi'
|
|
||||||
takeit.density = 0
|
|
||||||
takeit.anchored = 1
|
|
||||||
takeit.icon_state = "takefxb"
|
|
||||||
takeit.layer = 5
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
takeit.screen_loc = takeloc
|
|
||||||
flick("takefx", takeit)
|
|
||||||
playsound(get_turf(X.loc), 'sound/effects/sparks2.ogg', 100, 1)
|
|
||||||
|
|
||||||
//var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
|
||||||
// s.set_up(1, 1, X.loc)
|
|
||||||
// s.start()
|
|
||||||
consume(X)
|
|
||||||
countit += 1
|
|
||||||
sleep(3)
|
|
||||||
del(takeit)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// Turf and movable atoms
|
|
||||||
else if(dist <= consume_range && (isturf(X) || istype(X, /atom/movable)))
|
|
||||||
|
|
||||||
consume(X)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////serious change/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// Movable atoms only
|
|
||||||
if(dist > consume_range) //if outside the sing
|
|
||||||
var/pullable = canPull(X) //check if we can pull
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//world << "<font size='1' color='red'><b>[X.type]/b></font>" //debugging
|
|
||||||
if(istype(X, /mob) && (pullable == 1)) //are you a pullable mob?
|
|
||||||
|
|
||||||
if(pick(0,1))
|
|
||||||
step_towards(X,src)
|
|
||||||
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
if((countit < eatlimit) || current_size == 1) //are you allowed to eat? being fat causes lag
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(pick(0,1))//dont eat everything at once
|
|
||||||
|
|
||||||
if((current_size >= 9) || (pullable == 1)) //is the sing a monster or is this item pullable? if not gtfo
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//alright item, prepare to get rekt
|
|
||||||
|
|
||||||
spawn(0)
|
|
||||||
|
|
||||||
var/takeloc = get_turf(X.loc)
|
|
||||||
var/obj/machinery/singularity/takeit = new /atom/movable/overlay( takeloc )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
takeit.icon = 'icons/obj/singularity.dmi'
|
|
||||||
takeit.density = 0
|
|
||||||
takeit.anchored = 1
|
|
||||||
takeit.icon_state = "takefxb"
|
|
||||||
takeit.layer = 5
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
takeit.screen_loc = takeloc
|
|
||||||
flick("takefx", takeit)
|
|
||||||
playsound(get_turf(X.loc), 'sound/effects/sparks2.ogg', 100, 1)
|
|
||||||
|
|
||||||
//var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
|
||||||
// s.set_up(1, 1, X.loc)
|
|
||||||
// s.start()
|
|
||||||
consume(X)
|
|
||||||
countit += 1
|
|
||||||
sleep(3)
|
|
||||||
del(takeit)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Turf and movable atoms
|
|
||||||
else if(dist <= consume_range && (isturf(X) || istype(X, /atom/movable))) //of course if you are all up in the biz yer done, i guess eat all this up asap
|
|
||||||
|
|
||||||
consume(X)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////end change/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(defer_powernet_rebuild != 2)
|
|
||||||
defer_powernet_rebuild = 0
|
defer_powernet_rebuild = 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Singulo optimization.
|
||||||
|
* Jump out whenever we've made a decision.
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////this too
|
*/
|
||||||
|
/obj/machinery/singularity/proc/canPull(const/atom/movable/A)
|
||||||
// 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 we're big enough, stop checking for this and that and JUST EAT.
|
||||||
// if(current_size >= 9)
|
if (current_size >= 9)
|
||||||
// return 1
|
return 1
|
||||||
// else
|
|
||||||
// if(A && !A.anchored)
|
|
||||||
// if(A.canSingulothPull(src))
|
|
||||||
// return 1
|
|
||||||
|
|
||||||
|
if (A && !A.anchored)
|
||||||
|
if (A.canSingulothPull(src))
|
||||||
if(A && !A.anchored)
|
|
||||||
if(A.canSingulothPull(src))
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/obj/machinery/singularity/proc/consume(var/atom/A)
|
/obj/machinery/singularity/proc/consume(const/atom/A)
|
||||||
var/gain = 0
|
var/gain = 0
|
||||||
if(is_type_in_list(A, uneatable))
|
|
||||||
|
if (is_type_in_list(A, uneatable))
|
||||||
return 0
|
return 0
|
||||||
if (istype(A,/mob/living))//Mobs get gibbed
|
|
||||||
|
if (istype(A, /mob/living)) // Mobs get gibbed.
|
||||||
var/mob/living/M = A
|
var/mob/living/M = A
|
||||||
gain = 20
|
gain = 20
|
||||||
if(istype(M,/mob/living/carbon/human))
|
|
||||||
|
if (istype(M, /mob/living/carbon/human))
|
||||||
var/mob/living/carbon/human/H = M
|
var/mob/living/carbon/human/H = M
|
||||||
if(H.mind)
|
|
||||||
switch(H.mind.assigned_role)
|
if (H.mind)
|
||||||
if("Station Engineer","Chief Engineer")
|
switch (H.mind.assigned_role)
|
||||||
|
if ("Station Engineer", "Chief Engineer")
|
||||||
gain = 100
|
gain = 100
|
||||||
if("Clown")
|
if ("Clown")
|
||||||
gain = rand(-300, 300) // HONK
|
gain = rand(-300, 300) // HONK.
|
||||||
M.gib()
|
M.gib()
|
||||||
// Why
|
else if (istype(A,/obj/))
|
||||||
sleep(1)
|
if (istype(A, /obj/item/weapon/storage/backpack/holding))
|
||||||
else if(istype(A,/obj/))
|
var/dist = max((current_size - 2), 1)
|
||||||
|
explosion(get_turf(src), dist, dist * 2, dist * 4)
|
||||||
if (istype(A,/obj/item/weapon/storage/backpack/holding))
|
|
||||||
var/dist = max((current_size - 2),1)
|
|
||||||
explosion(src.loc,(dist),(dist*2),(dist*4))
|
|
||||||
return
|
return
|
||||||
if(istype(A, /obj/machinery/singularity))//Welp now you did it
|
|
||||||
|
if (istype(A, /obj/machinery/singularity)) //Welp now you did it.
|
||||||
var/obj/machinery/singularity/S = A
|
var/obj/machinery/singularity/S = A
|
||||||
src.energy += (S.energy/2)//Absorb most of it
|
energy += (S.energy / 2) // Absorb most of it.
|
||||||
del(S)
|
qdel(S)
|
||||||
var/dist = max((current_size - 2),1)
|
var/dist = max((current_size - 2),1)
|
||||||
explosion(src.loc,(dist),(dist*2),(dist*4))
|
explosion(get_turf(src), dist, dist * 2, dist * 4)
|
||||||
return//Quits here, the obj should be gone, hell we might be
|
return
|
||||||
|
|
||||||
if((teleport_del) && (!istype(A, /obj/machinery)))//Going to see if it does not lag less to tele items over to Z 2
|
qdel(A)
|
||||||
qdel(A)
|
|
||||||
else
|
|
||||||
A.ex_act(1.0)
|
|
||||||
if(A)
|
|
||||||
qdel(A)
|
|
||||||
gain = 2
|
gain = 2
|
||||||
else if(isturf(A))
|
else if (isturf(A))
|
||||||
var/turf/T = A
|
var/turf/T = A
|
||||||
if(T.intact)
|
T.ChangeTurf(/turf/space)
|
||||||
for(var/obj/O in T.contents)
|
gain = 2
|
||||||
if(O.level != 1)
|
|
||||||
continue
|
|
||||||
if(O.invisibility == 101)
|
|
||||||
src.consume(O)
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////break this up
|
|
||||||
if(pick(1,0))
|
|
||||||
T.ChangeTurf(/turf/space)
|
|
||||||
gain = 3
|
|
||||||
src.energy += gain
|
|
||||||
return
|
|
||||||
|
|
||||||
|
energy += gain
|
||||||
|
|
||||||
/obj/machinery/singularity/proc/move(var/force_move = 0)
|
/obj/machinery/singularity/proc/move(var/force_move = 0)
|
||||||
if(!move_self)
|
if(!move_self)
|
||||||
|
|||||||
Reference in New Issue
Block a user