void
void copied to clipboard
Interaction feedback for bots
The current interaction system was built for the client, where messages are sent and no response is expected. As such bots also fire and forget actions inbetween carefully constructed delays and often get stuck when an action fails.
There's also no consistency in the bot API, some methods return results, others throw exceptions when actions aren't avaliable, some fail quietly.
Using coroutines comes with hidden performance costs.
[GameLoop] - InstructionTask took 1ms
[GameLoop] - Scheduler took 1ms
[GameLoop] - PathTask took 98ms
[GameLoop] - MovementTask took 9ms
[GameLoop] - AiTick took 62ms
[GameLoop] - AiTick yield took 58ms
[GameLoop] - Tick 133 took 233ms
One way to resolve this would be to add objects between client packet encoding. This would allow the client instant to encode immediately, and the bot client to hand the object and it's data over to a coroutine to process and emit more instructions.
This also has the benefit of meaning bot code doesn't have to hook directly into the game engine events which would be better for #324. However this could add more complexity and the bot client will have to track information independently (where the player is, what they have in their inventory, equipment & bank, items on the floor etc...) to determine when they've finished the current task, finished moving/stuck/close to reaching target
Another way would be to implement a feedback mechanism into Interactions/Interact so events are emitted when interactions fail or are successful; much like the timers are doing today. You could have a finished event in a finish block wrapped around the whole thing when emitted that way only success() needs to be called when successful all other returns will have success set as false.
It might also be nice to extract all the bot scripts into it's own module, if possible.