Another update

This commit is contained in:
Markolie
2015-10-03 01:14:26 +02:00
parent e9188f7f38
commit 710d60c7bc
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -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
return 0
@@ -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)