Loading...
 

PogamutUT2004


Detecting Health Pack Pick Up

I'm trying to see how many health packs does the bot take for certain time. Is there a way to know or create an event when a health pack is acquired by the bot?
I'm using Pogamut 3.1 RC1
You need to create a listener for ItemPickedUp event. Something like this:

int healthItemCount = 0;

    //Listener to ItemPickedUp event
    IWorldEventListener myListener = new IWorldEventListener() {
        public void notify(ItemPickedUp event) {
            if (event.getType() == ItemType.MINI_HEALTH_PACK
                    || event.getType() == ItemType.HEALTH_PACK
                    || event.getType() == ItemType.SUPER_HEALTH_PACK)
                healthItemCount++;
        }
    };

    @Override
    public void botInitialized(GameInfo info, ConfigChange currentConfig, InitedMessage init) {
        //Don't forget to register the listener!
        getWorldView().addEventListener(ItemPickedUp.class, myListener);
    }


Don't forget to register the listener in botInitialized method as shown above. Does this help?

best,
Michal

PS.: There are tutorials here - that can help you get started.
That helped, I missed registering the listener in botInitialized. Now it's working perfectly fine.
Thanks
 

News

News RSS RSS feed for News link



Pogamut

Quarterly RSS RSS feed for quarterly reports

Acknowledgement

This work is supported by GA UK 1053/2007/A-INF/MFF (2007-8), GA UK 351/2006/A-INF/MFF (2006-8), the Ministry of Education of the Czech Republic (grant MSM0021620838) (2008-9), by the Program "Information Society" under project 1ET100300517 (2006-9), and the project Integration of IT Tools into Education of Humanities (2006-8) and by the project CZ.2.17/3.1.00/31162, which are financed by the European Social Fund, the state budget of the Czech Republic, and by the budget of Municipal House Prague.