[Pogamut-list] Detecting Health Pack Pick Up

michal.bida pogamut-forum at diana.ms.mff.cuni.cz
Sun Nov 21 23:29:25 CET 2010


Re: Detecting Health Pack Pick Up

Author: michal.bida

You need to create a listener for ItemPickedUp event. Something like this:

{CODE()}
    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);
    }
{CODE}

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

best,
Michal

PS.: There are [http://diana.ms.mff.cuni.cz/pogamut_files/latest/doc/tutorials/|tutorials here] - that can help you get started.

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=406&post_reply=1#form>





More information about the Pogamut-list mailing list