Feedback from BWAPI when targeted position is occupied after build command is isseud?
Can we get any feedback from BWAPI (e.g., via events, callback functions) that can notify the caller a failure has occured when a worker is trying to settle down a structure in a specific position?
For example, consider the following scenario. The player issues a build command to a SCV with a target position to build a structure. That position is far away from the current position of the assigned SCV, so the SCV has to move to the target position. This may take some time. After a while, the SCV reaches near by the target position, tries to settle down the structure. However, at this point, it finds the target position has been occupied by other units. As a result, the structure is not going to be constructed?
In this situcation, StarCraft will seed a feedback to a human player saying that the construction is not going to start. Can we get a feedback as well from BWAPI within this situation?
Game.getLastError() provides this information: https://bwapi.github.io/class_b_w_a_p_i_1_1_game.html#ac10b6a4c8fb868151bef1901b859f44e
The different kinds of errors: https://bwapi.github.io/namespace_b_w_a_p_i_1_1_errors.html
Game.getLastError() provides this information: https://bwapi.github.io/class_b_w_a_p_i_1_1_game.html#ac10b6a4c8fb868151bef1901b859f44e
The different kinds of errors: https://bwapi.github.io/namespace_b_w_a_p_i_1_1_errors.html
If in the same frame, there are multiple errors happening, I guess in this case some of those errors will be overwritten. Is that correct?
If I call getLastError() multiple times in the same frame, is it possible that I can get different error types? For example, I issue a command to a unit (e.g., attack), and then I call this function immediately (next line of code) after I issue the command to a unit. Will the error code get updated in the same frame, if some error is expected to the command I just issued (e.g., the target of an attack command does not exist)?
BWAPI doesn't have this functionality yet.
The way lastError works is it gets set during a function call and does not change otherwise. If there would be multiple errors only the first is returned, i.e. not enough minerals for the frame that you called it on, not the frame that Starcraft processes the command. So a command can succeed in BWAPI but fail in Starcraft (no error feedback).
For example, I issue a command to a unit (e.g., attack), and then I call this function immediately (next line of code) after I issue the command to a unit. Will the error code get updated in the same frame, if some error is expected to the command I just issued (e.g., the target of an attack command does not exist)?
If there's a problem with the command BWAPI will return false and set lastError to something, then you can check it with getLastError. But if you successfully issued the command in BWAPI but the target disappeared (thus making it invalid) and it gave an error in Starcraft you wouldn't get any feedback.
Same with ordering a worker to construct something, if another unit runs in the way there's no way to get feedback from BWAPI specifically for that.