Open Bobbyperson opened 6 months ago
This is also one of the things the non-streamlined version of giveWay
fixes. It can work as a quick fix.
https://github.com/V1kingGit/screeps-simple-stuck-fix/blob/34324c09f9971c3cf7fb67cc0986d0bbea7b9dda/giveWay.js#L116-L119
It (along with the fetchXYArguments function) adds a lot of unneeded complexity because of how moveTo
works. Ideally I would rather recommend creating your own version of moveTo
, where it would be much simpler to achieve this behavior simply through something that looks like the following:
Creep.prototype.moveToEx = function(targetPos)
{
if(this.pos.x === targetPos.x
&& this.pos.y === targetPos.y
&& this.pos.roomName === targetPos.roomName)
return true;
//...
Where you can either call moveTo
itself, or more ideally replace it completely and go directly to moveByPath
or move
.
While it's nice that these modules otherwise work out-of-the-box, it's ultimately meant to be a simple and understandable example for you to implement in your own codebase and work off of.
Therefore it may be better to let the user decide how to solve this, rather than implementing a bad solution that makes the example significantly harder to understand. I only made the exception for giveWay
by giving it two files, because it also solved other issues that were more common.
It does make sense to keep this issue open still for people to consider.
If a creep is on or in range of a moveTo goal, it will think it's stuck. Not sure if this is worth fixing as it could highlight a programming error on the user's part, but it may cost performance if it's attempting to repath more than usual. Steps to reproduce:
creep.moveTo(x, y)
(optionally, include a range)