Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

creep.moveTo doesn't return ERR_NO_PATH when all paths are blocked by creeps #63

Open
michael-s-crouch opened this issue Oct 22, 2017 · 2 comments

Comments

@michael-s-crouch
Copy link

I've been using creep.moveTo with ignoreCreeps: false, and I've noticed that if all paths are blocked by creeps, my creep will just walk to those creeps and then not do anything. The API says that ERR_NO_PATH should be returned when no path is found, but creep.moveTo is instead returning 0 in this case, even though all paths are blocked.

@sparr
Copy link
Contributor

sparr commented Oct 22, 2017

Are you sure you aren't using reusePath and the creep has a memorized path that hasn't expired yet?

@fiher
Copy link

fiher commented Apr 16, 2018

I have noticed similar issue. So far it seems that the problem comes from the fact that the path finding for this function returns unfinished path if the location is blocked.

If you are 10 tiles away from your location and only all tiles in range of 1 are blocked the path finder will provide you with path...but it will be one tile short. And your creep will move...1 tile short of its initial destination.

If you are however in range of 2 tiles and all tiles in range of 1 are blocked the path finder will not give you any path...resulting in ERR_NO_PATH being given.

However, this implementation works for sources and other structures on which you can't walk over without providing range:1 property to moveTo.

if(creep.harvest(source) === ERR_NOT_IN_RANGE){ creep.moveTo(source) }

This currently works...you will be given a path 1 tile away from the source...move to it..and stop receiving ERR_NOT_IN_RANGE.

However if this fix is to be implemented such code will return ERR_NO_PATH since there is no path that leads to the exact location (x,y).

In addition if you were to add default range:1 then when moving to flags or containers or any other walkable object...you will stop 1 tile short.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants