colobot icon indicating copy to clipboard operation
colobot copied to clipboard

Add a way to check if an object is on the way between bot and destination

Open Zemogiter opened this issue 1 year ago • 1 comments
trafficstars

Unless there's a undocumented function somewhere, I don't see a way to do it in CBot. The closest thing I came up with is this:

point midPoint;
midPoint.x = ((position.x + pos.x) / 2);
midPoint.y = ((position.y + pos.y) / 2);
midPoint.z = ((position.z + pos.z) / 2);
goto(midPoint);

Which is a point between bot (position) and destination (pos). What I'm trying to do is write a program that tells the bot to go to a point while following a path of Power Captors.

Zemogiter avatar May 18 '24 15:05 Zemogiter

I don't understand. Are you asking to add a new function-like instruction? What do you want the inputs to be? What do you want the return value to be?

hexagonrecursion avatar Jun 10 '24 09:06 hexagonrecursion

I think what you are trying to achieve can be accomplished with the existing CBot features.

Pseudocode:

while the destination is more than 50 meters from your current position {
    use radarall or searchall to find all Power Captors within 100 meters from your current position
    compute the distance from the Power Captors to the destination and select the closest
    go to the selected Power Captor
}
go to destination

hexagonrecursion avatar Oct 26 '24 10:10 hexagonrecursion