From 710d60c7bcb670caac02057b643436c54db66287 Mon Sep 17 00:00:00 2001 From: Markolie Date: Sat, 3 Oct 2015 01:14:26 +0200 Subject: [PATCH] Another update --- code/defines/procs/AStar.dm | 13 ++++++++----- code/game/gamemodes/changeling/powers/tiny_prick.dm | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/code/defines/procs/AStar.dm b/code/defines/procs/AStar.dm index e8b4b9c0d89..1479db76e5d 100644 --- a/code/defines/procs/AStar.dm +++ b/code/defines/procs/AStar.dm @@ -70,6 +70,13 @@ Actual Adjacent procs : //the actual algorithm /proc/AStar(start, end, atom, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableAdjacentTurfs, id=null, turf/exclude=null, simulated_only = 1) + + if(maxnodes) + //if start turf is farther than maxnodes from end turf, no need to do anything + if(call(start, dist)(end) > maxnodes) + return 0 + maxnodedepth = maxnodes //no need to consider path longer than maxnodes + var/Heap/open = new /Heap(/proc/HeapPathWeightCompare) //the open list var/list/closed = new() //the closed list var/list/path = null //the returned path, if any @@ -135,10 +142,6 @@ Actual Adjacent procs : for(var/turf/T in closed) T.PNode = null - //if the path is longer than maxnodes, then don't return it - if(path && maxnodes && path.len > (maxnodes + 1)) - return 0 - //reverse the path to get it from start to finish if(path) for(var/i = 1; i <= path.len/2; i++) @@ -197,4 +200,4 @@ Actual Adjacent procs : for(var/obj/machinery/door/D in T) if(!D.CanAStarPass(ID, dir)) return 1 - return 0 \ No newline at end of file + return 0 diff --git a/code/game/gamemodes/changeling/powers/tiny_prick.dm b/code/game/gamemodes/changeling/powers/tiny_prick.dm index ecc67496fae..050f9a74b8e 100644 --- a/code/game/gamemodes/changeling/powers/tiny_prick.dm +++ b/code/game/gamemodes/changeling/powers/tiny_prick.dm @@ -40,7 +40,7 @@ if(!isturf(user.loc)) return if(!AStar(user.loc, target.loc, null, /turf/proc/Distance, user.mind.changeling.sting_range, simulated_only = 0)) - return //hope this ancient magic still works + return if(target.mind && target.mind.changeling) sting_feedback(user,target) take_chemical_cost(user.mind.changeling)