[Pogamut-list] Controlling Bot
jakub.gemrot
pogamut-forum at diana.ms.mff.cuni.cz
Tue Dec 21 07:42:46 CET 2010
Re: Controlling Bot
Author: jakub.gemrot
Hi!
Your code looks perfectly fine, almost, you should not set "id of the enemy" as the name for your observer (it is probably not hurting anything but...).
{code()}
IUT2004Observer obs = new UT2004ObserverRunner(new UT2004ObserverFactory(new UT2004ObserverModule()), "Observer" + enemy.getId().getStringId()).startAgent();
{code}
... should be more suitable.
Also [lease not that we have not used UT2004Observer too much yet so it is possible for you to stumble upon a few bugs.
I fear that this will be the case of "BotDamaged" event - I will check it out.
But regarding NavPoints, I might have a solution. The trick is, that Observer Connection (i.e., port 3002 of GameBots2004) is not exporting all navpoints and items automatically.
But there are commands which enforce GameBots2004 to do so.
http://diana.ms.mff.cuni.cz/pogamut_files/latest/doc/javadoc/cz/cuni/amis/pogamut/ut2004/communication/messages/gbcommands/GetAllInvetories.html\
http://diana.ms.mff.cuni.cz/pogamut_files/latest/doc/javadoc/cz/cuni/amis/pogamut/ut2004/communication/messages/gbcommands/GetAllNavPoints.html
The trick is, that this exports will take some time to process, so you will have to wait for that. That's where WorldEventFuture will come in hand.
So I would suggest you to:
{code()}
WorldEventFuture latch = new WorldEventFuture(obs.getWorldView(), NavPointListEnd.class);
obs.getAct().act(new GetAllInventories());
obs.getAct().act(new GetAllNavPoints());
latch.get(); // will block, until all items / navpoints are exported
{code}
After that, all Items/Navpoints should be accessible inside obs.getWorldView() as usual for the bot.
Does it help?
Jimmy
--
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=446&post_reply=1#form>
More information about the Pogamut-list
mailing list