public class ImprovedShooting extends AdvancedShooting
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:
ImprovedShooting#shootNow(WeaponPrefs, Player, ItemType...)
ImprovedShooting#shoot(WeaponPrefs, Player, ItemType...)
act, worldView
agent, controller, eventBus, log
Constructor and Description |
---|
ImprovedShooting(Weaponry weaponry,
UT2004Bot agent,
Logger log) |
Modifier and Type | Method and Description |
---|---|
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'. |
reset, shoot, shoot, shoot, shootPrimary, shootPrimary, shootPrimary, shootPrimaryCharged, shootPrimaryCharged, shootPrimaryCharged, shootSecondary, shootSecondary, shootSecondary, shootSecondary, shootSecondaryCharged, shootSecondaryCharged, shootSecondaryCharged, shootWithMode, stopShoot, stopShooting
shoot
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, resume, start, stop, toString
public boolean mayChangeWeapon()
setChangeWeaponCooldown(long)
).public WeaponPref getActualWeaponPref()
WeaponPref
for actually used weapon.protected ItemType getActualWeaponType()
WeaponPref
for actually used weapon.public boolean changeWeapon(ItemType weaponType)
Obeys getChangeWeaponCooldown()
.
weaponType
- public boolean changeWeapon(Weapon weapon)
Obeys getChangeWeaponCooldown()
.
weapon
- public boolean changeWeapon(WeaponPref pref)
Obeys getChangeWeaponCooldown()
.
pref
- public WeaponPref changeWeapon(WeaponPrefs weaponPrefs, ItemType... forbiddenWeapons)
Obeys getChangeWeaponCooldown()
.
weaponPrefs
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
)public WeaponPref changeWeapon(WeaponPrefs weaponPrefs, double distance, ItemType... forbiddenWeapons)
Obeys getChangeWeaponCooldown()
.
weaponPrefs
- distance
- choose weapon according to distanceforbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
)public WeaponPref changeWeapon(WeaponPrefs weaponPrefs, ILocated target, ItemType... forbiddenWeapons)
Obeys getChangeWeaponCooldown()
.
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
)public boolean changeWeaponNow(ItemType weaponType)
DOES NOT OBEY getChangeWeaponCooldown()
.
weaponType
- public boolean changeWeaponNow(Weapon weapon)
DOES NOT OBEY getChangeWeaponCooldown()
.
weapon
- public boolean changeWeaponNow(WeaponPref pref)
DOES NOT OBEY getChangeWeaponCooldown()
.
pref
- public WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs, ItemType... forbiddenWeapons)
DOES NOT OBEY getChangeWeaponCooldown()
.
weaponPrefs
- public WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs, double distance, ItemType... forbiddenWeapons)
DOES NOT OBEY getChangeWeaponCooldown()
.
weaponPrefs
- distance
- choose weapon according to distanceforbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
)public WeaponPref changeWeaponNow(WeaponPrefs weaponPrefs, ILocated target, ItemType... forbiddenWeapons)
DOES NOT OBEY getChangeWeaponCooldown()
.
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
)public boolean shoot(WeaponPref pref, UnrealId target)
WeaponPref.getWeapon()
primary/secondary (as specified) at 'target'.
Obeys getChangeWeaponCooldown()
. If cooldown has not been reached yet, it will keep firing with
current weapon.
pref
- target
- public boolean shoot(WeaponPref pref, ILocated target)
WeaponPref.getWeapon()
primary/secondary (as specified) at 'target'.
Obeys getChangeWeaponCooldown()
. If cooldown has not been reached yet, it will keep firing with
current weapon.
pref
- target
- public boolean shoot(Weapon weapon, boolean usePrimaryMode, UnrealId target)
Weapon.getType()
primary/secondary (as specified) at 'target'.
Obeys getChangeWeaponCooldown()
.
weapon
- usePrimaryMode
- target
- public boolean shoot(Weapon weapon, boolean usePrimaryMode, ILocated target)
Weapon.getType()
primary/secondary (as specified) at 'target'.
Obeys getChangeWeaponCooldown()
.
weapon
- usePrimaryMode
- target
- public WeaponPref shoot(WeaponPrefs prefs, ILocated target, ItemType... forbiddenWeapon)
Obeys getChangeWeaponCooldown()
.
prefs
- target
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
).public boolean shootNow(WeaponPref pref, UnrealId target)
WeaponPref.getWeapon()
primary/secondary (as specified) at 'target'.
DOES NOT OBEY getChangeWeaponCooldown()
.
pref
- target
- public boolean shootNow(WeaponPref pref, ILocated target)
WeaponPref.getWeapon()
primary/secondary (as specified) at 'target'.
DOES NOT OBEY getChangeWeaponCooldown()
.
pref
- target
- public boolean shootNow(Weapon weapon, boolean usePrimaryMode, UnrealId target)
Weapon.getType()
primary/secondary (as specified) at 'target'.
DOES NOT OBEY getChangeWeaponCooldown()
.
weapon
- usePrimaryMode
- target
- public boolean shootNow(Weapon weapon, boolean usePrimaryMode, ILocated target)
Weapon.getType()
primary/secondary (as specified) at 'target'.
DOES NOT OBEY getChangeWeaponCooldown()
.
weapon
- usePrimaryMode
- target
- public WeaponPref shootNow(WeaponPrefs prefs, ILocated target, ItemType... forbiddenWeapon)
DOES NOT OBEY getChangeWeaponCooldown()
.
prefs
- target
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
).public WeaponPref getLastShooting()
StopShooting
command.
May be null!
public long getLastChangeWeapon()
System.currentTimeMillis()
when the bot changed the weapon for the last time.public long getChangeWeaponCooldown()
DOES NOT APPLY GENERALLY TO ALL ChangeWeapon
COMMANDS! Just for methods that are NOT SUFFIXED with 'Now' in this class!
public void setChangeWeaponCooldown(long changeWeaponCooldownMillis)
DOES NOT APPLY GENERALLY TO ALL ChangeWeapon
COMMANDS! Just for changeWeapon(ItemType)
methods
defined here!
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.