|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT> cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule<UDKBot> cz.cuni.amis.pogamut.udk.agent.module.sensomotoric.Weaponry
public class Weaponry
Memory module specialized on info about the bot's weapon inventory.
It listens to various events that provides information about weapons the bot picks up as well as weapon's ammo
grouping it together and providing Weapon
abstraction of bot's weaponry.
It also provides a way for easy weapon changing via changeWeapon(ItemType)
and changeWeapon(Weapon)
.
It is designed to be initialized inside IUT2004BotController#prepareBot(UT2004Bot)
method call
and may be used since IUT2004BotController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)
is called.
Hardened version - immune to NPEs (hopefully).
Field Summary |
---|
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule |
---|
act, worldView |
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
agent, controller, eventBus, log |
Constructor Summary | |
---|---|
Weaponry(UDKBot bot)
Constructor. |
|
Weaponry(UDKBot bot,
ItemDescriptors itemDescriptors)
Constructor. |
|
Weaponry(UDKBot bot,
ItemDescriptors descriptors,
LogCategory moduleLog)
Constructor. |
Method Summary | |
---|---|
protected void |
cleanUp()
|
int |
getAmmo(ItemType ammoOrWeaponType)
Returns an amount of ammo of 'ammoOrWeaponType' the bot currently has. |
Map<ItemType,Integer> |
getAmmos()
Returns a map with current state of ammo (ammo for owned weapons as well as ammo for weapons that the bot do not have yet). |
int |
getCurrentAlternateAmmo()
Tells, how much ammo is in the agent's inventory for current weapon for alternate firing mode. |
int |
getCurrentAmmo()
Tells, how much ammo is in the agent's inventory for current weapon - primary + (if has different secondary ammo type) alternate (secondary). |
int |
getCurrentPrimaryAmmo()
Tells, how much ammo is in the agent's inventory for current weapon. |
Weapon |
getCurrentWeapon()
Retrieves current weapon from the agent's inventory. |
WeaponDescriptor |
getDescriptorForId(UnrealId inventoryWeaponId)
Returns WeaponDescriptor for a given inventory UnrealId of the weapon. |
ItemType |
getItemTypeForId(UnrealId inventoryWeaponId)
Returns an item type for a given inventory UnrealId of the weapon. |
Map<ItemType,Weapon> |
getLoadedMeleeWeapons()
Retrieves loaded melee weapons from the agent's inventory. |
Map<ItemType,Weapon> |
getLoadedRangedWeapons()
Retrieves loaded ranged weapons from the agent's inventory. |
Map<ItemType,Weapon> |
getLoadedWeapons()
Retrieves all loaded weapons from the agent's inventory. |
int |
getMaxAmmo(ItemType ammoType)
Returns max ammo that the bot may have for a specified ammo type. |
Map<ItemType,Weapon> |
getMeleeWeapons()
Retrieves melee weapons from the agent's inventory. |
int |
getPrimaryWeaponAmmo(ItemType weaponType)
Returns an amount of primary ammo of a given 'weaponType' the bot currently has. |
ItemType |
getPrimaryWeaponAmmoType(ItemType weaponType)
Return primary-ammo ItemType for a weapon. |
Map<ItemType,Weapon> |
getRangedWeapons()
Retrieves ranged weapons from the agent's inventory. |
int |
getSecondaryWeaponAmmo(ItemType weaponType)
Returns an amount of secondary ammo of a given 'weaponType' the bot currently has. |
ItemType |
getSecondaryWeaponAmmoType(ItemType weaponType)
Return secondary-ammo ItemType for a weapon. |
Weapon |
getWeapon(ItemType weaponType)
Returns Weapon instance for given 'weaponType' if the bot posses it. |
int |
getWeaponAmmo(ItemType weaponType)
Returns an amount of primary+secondary ammo of a given 'weaponType' the bot currently has. |
WeaponDescriptor |
getWeaponDescriptor(ItemType weaponType)
Returns a WeaponDescriptor for a given 'weaponType' (if it is not a weapon, returns null). |
ItemType |
getWeaponForAmmo(ItemType priOrSecAmmoType)
Returns weaponType for a given ammoType (regardles whether it is primary or secondary ammo type). |
UnrealId |
getWeaponInventoryId(ItemType weaponType)
Returns inventory UnrealId of the weapon the bot has inside its inventory (if the bot does not have
it, returns null). |
UnrealId |
getWeaponInventoryId(WeaponDescriptor weaponDescriptor)
Returns inventory UnrealId of the weapon the bot has inside its inventory (if the bot does not have
it, returns null). |
Map<ItemType,Weapon> |
getWeapons()
Retrieves all weapons from the agent's inventory. |
boolean |
hasAmmo(ItemType ammoType)
Tells whether the bot has an ammo of 'ammoType'. |
boolean |
hasAmmoForWeapon(ItemType weaponType)
Alias for hasWeaponAmmo(ItemType) . |
boolean |
hasLoadedMeleeWeapon()
Tells, whether the agent has any loaded melee weapon in the inventory. |
boolean |
hasLoadedRangedWeapon()
Tells, whether the agent has any loaded ranged weapon in the inventory. |
boolean |
hasLoadedWeapon()
Tells, whether the agent has any loaded weapon in the inventory. |
boolean |
hasLoadedWeapon(ItemType weapon)
Whether the bot possess 'weapon' that has primary or secondary ammo. |
boolean |
hasLowAmmoForWeapon(ItemType weaponType,
double lowRatio)
Tells whether the bot has low-ammo for "weaponType" (either primary/secondary). |
boolean |
hasPrimaryLoadedWeapon(ItemType weapon)
Whether the bot possess 'weapon' that has primary ammo. |
boolean |
hasPrimaryLowAmmoForWeapon(ItemType weaponType,
double lowRatio)
Tells whether the bot has primary low-ammo for "weaponType" Low ammo is: currAmmmo / maxAmmo < lowRatio |
boolean |
hasPrimaryWeaponAmmo(ItemType weaponType)
Tells whether the bot has a primary ammo for a given 'weaponType'. |
boolean |
hasSecondaryAmmoType(ItemType weaponType)
Whether the weapon has secondary ammo different from the primary. |
boolean |
hasSecondaryLoadedWeapon(ItemType weapon)
Whether the bot possess 'weapon' that has secondary ammo. |
boolean |
hasSecondaryLowAmmoForWeapon(ItemType weaponType,
double lowRatio)
Tells whether the bot has secondary low-ammo for "weaponType" Low ammo is: currAmmmo / maxAmmo < lowRatio |
boolean |
hasSecondaryWeaponAmmo(ItemType weaponType)
Tells whether the bot has a secondary ammo for a given 'weaponType'. |
boolean |
hasWeapon(ItemType.Group weaponGroup)
Tells, whether a weapon from the specific group is in the agent's inventory. |
boolean |
hasWeapon(ItemType weaponType)
Tells, whether specific weapon is in the agent's inventory. |
boolean |
hasWeaponAmmo(ItemType weaponType)
Tells whether the bot has an ammo (either primary or secondary) for a given 'weaponType'. |
boolean |
changeWeapon(ItemType weaponType)
Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0). |
boolean |
changeWeapon(Weapon weapon)
Changes the weapon the bot is currently holding (if the weapon's ammo is > 0). |
boolean |
isLoaded(ItemType.Group weaponGroup)
Tells, whether a weapon from a specific group is in the agent's inventory && is loaded (has at least 1 primary or secondary ammo). |
boolean |
isLoaded(ItemType weaponType)
Tells, whether specific weapon is in the agent's inventory && is loaded (has at least 1 primary or secondary ammo). |
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Weaponry(UDKBot bot)
bot
- owner of the module that is using itpublic Weaponry(UDKBot bot, ItemDescriptors itemDescriptors)
bot
- owner of the module that is using itagentInfo
- AgentInfo memory module.itemDescriptors
- ItemDescriptors memory module.public Weaponry(UDKBot bot, ItemDescriptors descriptors, LogCategory moduleLog)
bot
- owner of the module that is using itagentInfo
- AgentInfo memory module.itemDescriptors
- ItemDescriptors memory module.moduleLog
- Method Detail |
---|
public WeaponDescriptor getDescriptorForId(UnrealId inventoryWeaponId)
WeaponDescriptor
for a given inventory UnrealId
of the weapon.
Note that there exists two types of UnrealId
for every weapon:
Item
)AddInventoryMsg
)
inventoryWeaponId
-
public ItemType getItemTypeForId(UnrealId inventoryWeaponId)
UnrealId
of the weapon.
Note that there exists two types of UnrealId
for every weapon:
Item
)AddInventoryMsg
)
inventoryWeaponId
-
public UnrealId getWeaponInventoryId(ItemType weaponType)
UnrealId
of the weapon the bot has inside its inventory (if the bot does not have
it, returns null).
Note that there exists two types of UnrealId
for every weapon:
Item
)AddInventoryMsg
)ChangeWeapon
command.
weaponType
-
public UnrealId getWeaponInventoryId(WeaponDescriptor weaponDescriptor)
UnrealId
of the weapon the bot has inside its inventory (if the bot does not have
it, returns null).
Note that there exists two types of UnrealId
for every weapon:
Item
)AddInventoryMsg
)ChangeWeapon
command.
weaponType
-
public boolean changeWeapon(ItemType weaponType)
weaponType
-
public boolean changeWeapon(Weapon weapon)
weapon
-
public int getAmmo(ItemType ammoOrWeaponType)
If an ammo type is passed - exact number is returned.
If an weapon type is passed - its primary + secondary ammo amount is returned.
If an invalid 'ammoType' is passed, 0 is returned.
ammoType
-
public int getPrimaryWeaponAmmo(ItemType weaponType)
If an invalid 'weaponType' is passed, 0 is returned.
weaponType
-
public int getSecondaryWeaponAmmo(ItemType weaponType)
If an invalid 'weaponType' is passed, 0 is returned.
weaponType
-
public int getWeaponAmmo(ItemType weaponType)
If an invalid 'weaponType' is passed, 0 is returned.
weaponType
-
public boolean hasLowAmmoForWeapon(ItemType weaponType, double lowRatio)
Low ammo is: currAmmmo / maxAmmo < lowRatio
weaponType
- lowRatio
-
public boolean hasSecondaryLowAmmoForWeapon(ItemType weaponType, double lowRatio)
Low ammo is: currAmmmo / maxAmmo < lowRatio
weaponType
- lowRatio
-
public boolean hasPrimaryLowAmmoForWeapon(ItemType weaponType, double lowRatio)
Low ammo is: currAmmmo / maxAmmo < lowRatio
weaponType
- lowRatio
-
public boolean hasAmmo(ItemType ammoType)
If an invalid 'ammoType' is passed, false is returned.
ammoType
-
public boolean hasAmmoForWeapon(ItemType weaponType)
hasWeaponAmmo(ItemType)
.
weaponType
-
hasWeaponAmmo(ItemType)
public boolean hasWeaponAmmo(ItemType weaponType)
If an invalid 'weaponType' is passed, false is returned.
weaponType
-
public boolean hasPrimaryWeaponAmmo(ItemType weaponType)
If an invalid 'weaponType' is passed, false is returned.
weaponType
-
public boolean hasSecondaryWeaponAmmo(ItemType weaponType)
If an invalid 'weaponType' is passed, false is returned.
weaponType
-
public boolean hasWeapon(ItemType weaponType)
If an invalid 'weaponType' is passed, false is returned.
weaponType
- type of the weapon
public boolean hasWeapon(ItemType.Group weaponGroup)
If an invalid 'weaponGroup' is passed, false is returned.
weaponGroup
- group of the weapon
public boolean isLoaded(ItemType weaponType)
If an invalid 'weaponType' is passed, false is returned.
weaponType
- type of the weapon
public boolean isLoaded(ItemType.Group weaponGroup)
If an invalid 'weaponGroup' is passed, false is returned.
weaponType
- type of the weapon
public boolean hasSecondaryAmmoType(ItemType weaponType)
If an invalid 'weaponType' is passed, false is returned.
weaponType
-
public WeaponDescriptor getWeaponDescriptor(ItemType weaponType)
WeaponDescriptor
for a given 'weaponType' (if it is not a weapon, returns null).
The descriptor can be used to reason about the weapon suitability for actual combat.
weaponType
-
public Weapon getCurrentWeapon()
getCurrentPrimaryAmmo()
,
getCurrentAlternateAmmo()
,
AgentInfo.getCurrentWeapon()
public int getCurrentAmmo()
getCurrentPrimaryAmmo()
,
getCurrentAlternateAmmo()
,
AgentInfo.getCurrentAmmo()
public int getCurrentPrimaryAmmo()
getCurrentAlternateAmmo()
,
AgentInfo.getCurrentAmmo()
public int getCurrentAlternateAmmo()
getCurrentPrimaryAmmo()
.
getCurrentPrimaryAmmo()
,
AgentInfo.getCurrentSecondaryAmmo()
public Map<ItemType,Weapon> getWeapons()
NOTE: Returned map can't be modified.
NOTE: The Weapon
instance is invalidated by BotKilled
event, discard the instance upon bot's death.
hasLoadedWeapon()
,
getLoadedMeleeWeapons()
,
getLoadedRangedWeapons()
public Weapon getWeapon(ItemType weaponType)
Weapon
instance for given 'weaponType' if the bot posses it.
weaponType
-
Weapon
getWeapons()
public Map<ItemType,Weapon> getLoadedWeapons()
Note: Shield guns are never treated as loaded weapons, though they are usually loaded, i.e. ready to be fired.
NOTE: Returned map can't be modified.
NOTE: The Weapon
instance is invalidated by BotKilled
event, discard the instance upon bot's death.
hasLoadedWeapon()
,
getLoadedMeleeWeapons()
,
getLoadedRangedWeapons()
public Map<ItemType,Weapon> getMeleeWeapons()
NOTE: Returned map can't be modified.
NOTE: The Weapon
instance is invalidated by BotKilled
event, discard the instance upon bot's death.
getLoadedMeleeWeapons()
public Map<ItemType,Weapon> getRangedWeapons()
NOTE: Returned map can't be modified.
NOTE: The Weapon
instance is invalidated by BotKilled
event, discard the instance upon bot's death.
getLoadedRangedWeapons()
public Map<ItemType,Weapon> getLoadedMeleeWeapons()
NOTE: Returned map can't be modified.
NOTE: The Weapon
instance is invalidated by BotKilled
event, discard the instance upon bot's death.
getMeleeWeapons()
public Map<ItemType,Weapon> getLoadedRangedWeapons()
NOTE: Returned map can't be modified.
NOTE: The Weapon
instance is invalidated by BotKilled
event, discard the instance upon bot's death.
getRangedWeapons()
public Map<ItemType,Integer> getAmmos()
NOTE: Returned map can't be modified.
public boolean hasLoadedWeapon()
Note: Shield guns are never treated as loaded weapons, though they are usually loaded, i.e. ready to be fired.
getLoadedWeapons()
public boolean hasLoadedRangedWeapon()
getLoadedRangedWeapons()
public boolean hasLoadedMeleeWeapon()
Note: Shield guns are never treated as loaded weapons, though they are usually loaded, i.e. ready to be fired.
getLoadedMeleeWeapons()
public boolean hasLoadedWeapon(ItemType weapon)
weapon
-
public boolean hasPrimaryLoadedWeapon(ItemType weapon)
weapon
-
public boolean hasSecondaryLoadedWeapon(ItemType weapon)
weapon
-
public ItemType getWeaponForAmmo(ItemType priOrSecAmmoType)
priOrSecAmmoType
-
public ItemType getPrimaryWeaponAmmoType(ItemType weaponType)
ItemType
for a weapon.
weaponType
-
public ItemType getSecondaryWeaponAmmoType(ItemType weaponType)
ItemType
for a weapon.
weaponType
-
protected void cleanUp()
cleanUp
in class AgentModule<UDKBot>
public int getMaxAmmo(ItemType ammoType)
Contributed by: David Holan
ammoType
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |