View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.agent.module.sensor;
2   
3   import java.util.ArrayList;
4   import java.util.Collections;
5   import java.util.HashMap;
6   import java.util.HashSet;
7   import java.util.Iterator;
8   import java.util.List;
9   import java.util.Map;
10  import java.util.Random;
11  import java.util.Set;
12  import java.util.logging.Logger;
13  
14  import cz.cuni.amis.pogamut.base.agent.module.SensorModule;
15  import cz.cuni.amis.pogamut.base.communication.worldview.IWorldView;
16  import cz.cuni.amis.pogamut.base.communication.worldview.event.IWorldEventListener;
17  import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObjectEvent;
18  import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObjectEventListener;
19  import cz.cuni.amis.pogamut.base.communication.worldview.object.event.WorldObjectUpdatedEvent;
20  import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
21  import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
22  import cz.cuni.amis.pogamut.ut2004.agent.module.utils.TabooSet;
23  import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
24  import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
25  import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
26  import cz.cuni.amis.pogamut.ut2004.communication.messages.UT2004ItemType;
27  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.EndMessage;
28  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Item;
29  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ItemPickedUp;
30  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
31  import cz.cuni.amis.pogamut.ut2004.communication.translator.shared.events.MapPointListObtained;
32  import cz.cuni.amis.pogamut.ut2004.utils.UnrealUtils;
33  import cz.cuni.amis.utils.NullCheck;
34  import cz.cuni.amis.utils.collections.MyCollections;
35  import cz.cuni.amis.utils.maps.HashMapMap;
36  
37  
38  public class UT2004Items extends Items {	
39  
40  	
41  	public UT2004Items(UT2004Bot bot, AgentInfo agentInfo, Game game, Weaponry weaponry, Logger log){
42  		super(bot, agentInfo, game, weaponry, log);
43  	}
44  	
45  	public boolean isPickable(Item item) {
46      	// health
47      	if ( item.getType() == UT2004ItemType.HEALTH_PACK && agentInfo.isHealthy() ) {
48      		return false;
49      	}
50      	if ( item.getType() == UT2004ItemType.SUPER_HEALTH_PACK && agentInfo.isSuperHealthy() ) {
51      		return false;
52      	}
53      	if ( item.getType() == UT2004ItemType.MINI_HEALTH_PACK && agentInfo.isSuperHealthy() ) {
54      		return false;
55      	}
56      	
57      	// shield
58      	if ( item.getType() == UT2004ItemType.SHIELD_PACK && agentInfo.hasLowArmor() ) {
59      		return false;
60      	}
61      	if ( item.getType() == UT2004ItemType.SUPER_SHIELD_PACK && agentInfo.hasHighArmor() ) {
62      		return false;
63      	}
64      	
65      	// weapons
66      	if ( item.getType().getCategory() == ItemType.Category.WEAPON ) {
67      		if ( game.getGameInfo().isWeaponStay() ) {
68      			return !weaponry.hasWeapon(item.getType());
69      		} else {
70      			return weaponry.getPrimaryWeaponAmmo( item.getType() ) < weaponry.getWeaponDescriptor( item.getType() ).getPriMaxAmount()
71      				   ||
72      				   weaponry.getSecondaryWeaponAmmo( item.getType() ) < weaponry.getWeaponDescriptor( item.getType() ).getSecMaxAmount();
73      		}
74      	}
75      	
76      	// ammo
77      	if ( item.getType().getCategory() == ItemType.Category.AMMO && weaponry.getAmmo(item.getType()) >= weaponry.getMaxAmmo(item.getType()) ) {
78      		return false;
79      	}
80      	
81      	// adrenaline
82      	if ( item.getType() == UT2004ItemType.ADRENALINE_PACK && agentInfo.isAdrenalineFull() ) {
83      		return false;
84      	}
85      	
86      	// ultra damage
87      	if ( item.getType() == UT2004ItemType.U_DAMAGE_PACK && agentInfo.hasUDamage() ) {
88      		return false;
89      	}
90  
91      	return true;
92  	}
93  
94  	public double getItemRespawnTime(ItemType itemType) {
95  		if (itemType == UT2004ItemType.U_DAMAGE_PACK) {
96  			return 3 * 27.5;
97  		} else
98  		if (itemType == UT2004ItemType.SUPER_SHIELD_PACK || itemType == UT2004ItemType.SUPER_HEALTH_PACK) {
99  			return 2 * 27.5;
100 		} else {
101 			return 27.5;
102 		}
103 	}
104 }