cz.cuni.amis.pogamut.ut2004.bot.command
Class ImprovedShooting

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT>
      extended by cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule<UT2004Bot>
          extended by cz.cuni.amis.pogamut.ut2004.bot.command.BotCommands
              extended by cz.cuni.amis.pogamut.ut2004.bot.command.SimpleShooting
                  extended by cz.cuni.amis.pogamut.ut2004.bot.command.AdvancedShooting
                      extended by cz.cuni.amis.pogamut.ut2004.bot.command.ImprovedShooting
All Implemented Interfaces:
IComponent

public class ImprovedShooting
extends AdvancedShooting

This shooting will allow you to define with which Weapon / / WeaponPrefs you want to shoot. It will also automatically handles rearming to the desired weapon if needed and watches over which weapon/firing mode you've used in previous logic iteration (if any).

Further more it allows you to define cool down that specify how often the bot may change its weapon via setChangeWeaponCooldown(long). But rest assured that this can be overriden as there are two types of method here:

  1. methods that DOES NOT OBEY the cooldown - they have suffix 'Now', e.g., ImprovedShooting#shootNow(WeaponPrefs, Player, ItemType...)
  2. methods that OBEY the cooldown - they DO NOT HAVE suffix 'Now', e.g., ImprovedShooting#shoot(WeaponPrefs, Player, ItemType...)


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
ImprovedShooting(Weaponry weaponry, UT2004Bot agent, java.util.logging.Logger log)
           
 
Method Summary
 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 bot has the weapon and its ammo > 0).
 boolean changeWeapon(WeaponPref pref)
          Changes the weapon the bot is currently holding (if the bot has the weapon and its primary/secondary (according to 'pref') ammo > 0).
 WeaponPref changeWeapon(WeaponPrefs weaponPrefs, double distance, ItemType... forbiddenWeapons)
          Arms the best weapon according to distance from 'weaponPrefs'.
 WeaponPref changeWeapon(WeaponPrefs weaponPrefs, ILocated target, ItemType... forbiddenWeapons)
          Arms the best weapon according to distance from 'weaponPrefs'.
 WeaponPref changeWeapon(WeaponPrefs weaponPrefs, ItemType... forbiddenWeapons)
          Arms the best weapon according to general preferences in 'weaponPrefs'.
 boolean changeWeaponNow(ItemType weaponType)
          Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0).
 boolean changeWeaponNow(Weapon weapon)
          Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0).
 boolean changeWeaponNow(WeaponPref pref)
          Changes the weapon the bot is currently holding (if the bot has the weapon and its primary/secondary (according to 'pref') ammo > 0).
 WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs, double distance, ItemType... forbiddenWeapons)
          Arms the best weapon according to distance from 'weaponPrefs'.
 WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs, ILocated target, ItemType... forbiddenWeapons)
          Arms the best weapon according to distance from 'weaponPrefs'.
 WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs, ItemType... forbiddenWeapons)
          Arms the best weapon according to general preferences in 'weaponPrefs'.
 WeaponPref getActualWeaponPref()
          Get WeaponPref for actually used weapon.
protected  ItemType getActualWeaponType()
          Get WeaponPref for actually used weapon.
 long getChangeWeaponCooldown()
          Returns how often the bot may change weapon.
 long getLastChangeWeapon()
          System.currentTimeMillis() when the bot changed the weapon for the last time.
 WeaponPref getLastShooting()
          Return last type of weapon / mode of firing you've used (or null, if you have issued StopShooting command.
 boolean mayChangeWeapon()
          Whether bot may change weapon (change weapon cooled down as defined by setChangeWeaponCooldown(long)).
 void setChangeWeaponCooldown(long changeWeaponCooldownMillis)
          Sets how often the bot may change weapon.
 boolean shoot(Weapon weapon, boolean usePrimaryMode, ILocated target)
          Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.
 boolean shoot(Weapon weapon, boolean usePrimaryMode, UnrealId target)
          Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.
 boolean shoot(WeaponPref pref, ILocated target)
          Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.
 WeaponPref shoot(WeaponPrefs prefs, ILocated target, ItemType... forbiddenWeapon)
          Will start shooting with the best weapon (according to 'prefs') at target.
 boolean shoot(WeaponPref pref, UnrealId target)
          Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.
 boolean shootNow(Weapon weapon, boolean usePrimaryMode, ILocated target)
          Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.
 boolean shootNow(Weapon weapon, boolean usePrimaryMode, UnrealId target)
          Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.
 boolean shootNow(WeaponPref pref, ILocated target)
          Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.
 WeaponPref shootNow(WeaponPrefs prefs, ILocated target, ItemType... forbiddenWeapon)
          Will start shooting with the best weapon (according to 'prefs') at target.
 boolean shootNow(WeaponPref pref, UnrealId target)
          Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.command.AdvancedShooting
reset, shoot, shoot, shoot, shootPrimary, shootPrimary, shootPrimary, shootPrimaryCharged, shootPrimaryCharged, shootPrimaryCharged, shootSecondary, shootSecondary, shootSecondary, shootSecondary, shootSecondaryCharged, shootSecondaryCharged, shootSecondaryCharged, shootWithMode, stopShoot, stopShooting
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.command.SimpleShooting
shoot
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, resume, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImprovedShooting

public ImprovedShooting(Weaponry weaponry,
                        UT2004Bot agent,
                        java.util.logging.Logger log)
Method Detail

mayChangeWeapon

public boolean mayChangeWeapon()
Whether bot may change weapon (change weapon cooled down as defined by setChangeWeaponCooldown(long)).

Returns:

getActualWeaponPref

public WeaponPref getActualWeaponPref()
Get WeaponPref for actually used weapon.

Returns:

getActualWeaponType

protected ItemType getActualWeaponType()
Get WeaponPref for actually used weapon.

Returns:

changeWeapon

public boolean changeWeapon(ItemType weaponType)
Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0).

Obeys getChangeWeaponCooldown().

Parameters:
weaponType -
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeapon

public boolean changeWeapon(Weapon weapon)
Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0).

Obeys getChangeWeaponCooldown().

Parameters:
weapon -
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeapon

public boolean changeWeapon(WeaponPref pref)
Changes the weapon the bot is currently holding (if the bot has the weapon and its primary/secondary (according to 'pref') ammo > 0).

Obeys getChangeWeaponCooldown().

Parameters:
pref -
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeapon

public WeaponPref changeWeapon(WeaponPrefs weaponPrefs,
                               ItemType... forbiddenWeapons)
Arms the best weapon according to general preferences in 'weaponPrefs'.

Obeys getChangeWeaponCooldown().

Parameters:
weaponPrefs -
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER)
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeapon

public WeaponPref changeWeapon(WeaponPrefs weaponPrefs,
                               double distance,
                               ItemType... forbiddenWeapons)
Arms the best weapon according to distance from 'weaponPrefs'.

Obeys getChangeWeaponCooldown().

Parameters:
weaponPrefs -
distance - choose weapon according to distance
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER)
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeapon

public WeaponPref changeWeapon(WeaponPrefs weaponPrefs,
                               ILocated target,
                               ItemType... forbiddenWeapons)
Arms the best weapon according to distance from 'weaponPrefs'.

Obeys getChangeWeaponCooldown().

Parameters:
weaponPrefs -
target - choose weapon according to distance to the target (from the bot)
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER)
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeaponNow

public boolean changeWeaponNow(ItemType weaponType)
Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0).

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weaponType -
Returns:
whether we have changed the weapon (i.e., we have some ammo for it), or we already have it prepared (i.e., is our current weapon)

changeWeaponNow

public boolean changeWeaponNow(Weapon weapon)
Changes the weapon the bot is currently holding (if the bot has the weapon and its ammo > 0).

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weapon -
Returns:
whether we have changed the weapon (i.e., we have some ammo for it), or we already have it prepared (i.e., is our current weapon)

changeWeaponNow

public boolean changeWeaponNow(WeaponPref pref)
Changes the weapon the bot is currently holding (if the bot has the weapon and its primary/secondary (according to 'pref') ammo > 0).

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
pref -
Returns:
whether we have changed the weapon (i.e., we have some ammo for required firing mode), or we already have it prepared (i.e., is our current weapon and we have enough ammo)

changeWeaponNow

public WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs,
                                  ItemType... forbiddenWeapons)
Arms the best weapon according to general preferences in 'weaponPrefs'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weaponPrefs -

changeWeaponNow

public WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs,
                                  double distance,
                                  ItemType... forbiddenWeapons)
Arms the best weapon according to distance from 'weaponPrefs'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weaponPrefs -
distance - choose weapon according to distance
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER)
Returns:
which weapon we have chosen, null == no suitable weapon found

changeWeaponNow

public WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs,
                                  ILocated target,
                                  ItemType... forbiddenWeapons)
Arms the best weapon according to distance from 'weaponPrefs'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weaponPrefs -
target - choose weapon according to distance to the target (from the bot)
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER)
Returns:
which weapon we have chosen, null == no suitable weapon found

shoot

public boolean shoot(WeaponPref pref,
                     UnrealId target)
Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.

Obeys getChangeWeaponCooldown(). If cooldown has not been reached yet, it will keep firing with current weapon.

Parameters:
pref -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shoot

public boolean shoot(WeaponPref pref,
                     ILocated target)
Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.

Obeys getChangeWeaponCooldown(). If cooldown has not been reached yet, it will keep firing with current weapon.

Parameters:
pref -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shoot

public boolean shoot(Weapon weapon,
                     boolean usePrimaryMode,
                     UnrealId target)
Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.

Obeys getChangeWeaponCooldown().

Parameters:
weapon -
usePrimaryMode -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shoot

public boolean shoot(Weapon weapon,
                     boolean usePrimaryMode,
                     ILocated target)
Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.

Obeys getChangeWeaponCooldown().

Parameters:
weapon -
usePrimaryMode -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shoot

public WeaponPref shoot(WeaponPrefs prefs,
                        ILocated target,
                        ItemType... forbiddenWeapon)
Will start shooting with the best weapon (according to 'prefs') at target.

Obeys getChangeWeaponCooldown().

Parameters:
prefs -
target -
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER).
Returns:
what the bot is shooting with

shootNow

public boolean shootNow(WeaponPref pref,
                        UnrealId target)
Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
pref -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shootNow

public boolean shootNow(WeaponPref pref,
                        ILocated target)
Will start shooting with WeaponPref.getWeapon() primary/secondary (as specified) at 'target'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
pref -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shootNow

public boolean shootNow(Weapon weapon,
                        boolean usePrimaryMode,
                        UnrealId target)
Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weapon -
usePrimaryMode -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shootNow

public boolean shootNow(Weapon weapon,
                        boolean usePrimaryMode,
                        ILocated target)
Will start shooting with Weapon.getType() primary/secondary (as specified) at 'target'.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
weapon -
usePrimaryMode -
target -
Returns:
whether the bot is shooting (i.e., has enough ammo to do so)

shootNow

public WeaponPref shootNow(WeaponPrefs prefs,
                           ILocated target,
                           ItemType... forbiddenWeapon)
Will start shooting with the best weapon (according to 'prefs') at target.

DOES NOT OBEY getChangeWeaponCooldown().

Parameters:
prefs -
target -
forbiddenWeapons - optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER).
Returns:
what weapon the bot is shooting with

getLastShooting

public WeaponPref getLastShooting()
Return last type of weapon / mode of firing you've used (or null, if you have issued StopShooting command.

May be null!

Returns:

getLastChangeWeapon

public long getLastChangeWeapon()
System.currentTimeMillis() when the bot changed the weapon for the last time.

Returns:

getChangeWeaponCooldown

public long getChangeWeaponCooldown()
Returns how often the bot may change weapon. Default: 1000 (1 second).

DOES NOT APPLY GENERALLY TO ALL ChangeWeapon COMMANDS! Just for methods that are NOT SUFFIXED with 'Now' in this class!

Returns:

setChangeWeaponCooldown

public void setChangeWeaponCooldown(long changeWeaponCooldownMillis)
Sets how often the bot may change weapon. Default: 1000 (1 second).

DOES NOT APPLY GENERALLY TO ALL ChangeWeapon COMMANDS! Just for changeWeapon(ItemType) methods defined here!