|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.ut2004.agent.module.sensor.WeaponPrefs
public class WeaponPrefs
Class that allows you to easily define weapon preferences for your bot as well as time how often you may change your weapon.
Use this class in IUT2004BotController.prepareBot(UT2004Bot)
, i.e., use methods such as addGeneralPref(ItemType, boolean)
,
newPrefsRange(double)
, WeaponPrefsRange.add(ItemType, boolean)
.
Preferences are never automatically wiped out!
Field Summary | |
---|---|
protected UT2004Bot |
bot
|
protected WeaponPrefsRange |
generalPrefs
|
protected WeaponPrefs |
onlyGeneral
|
protected java.util.List<WeaponPrefsRange> |
prefs
|
protected Weaponry |
weaponry
|
Constructor Summary | |
---|---|
|
WeaponPrefs(Weaponry weaponry,
UT2004Bot bot)
|
protected |
WeaponPrefs(Weaponry weaponry,
UT2004Bot bot,
WeaponPrefsRange generalPrefs)
|
Method Summary | |
---|---|
WeaponPrefs |
addGeneralPref(ItemType weapon,
boolean usePrimaryMode)
Adds another weapon as "the least preferable" one into general-preferences (used if no weapons are found for a given range) You may define weapons from the most preferred to the least preferred by sequentially calling this method. |
WeaponPrefs |
addGeneralPref(Weapon weapon,
boolean usePrimaryMode)
Adds another weapon as "the least preferable" one into general-preferences (used if no weapons are found for a given range) You may define weapons from the most preferred to the least preferred by sequentially calling this method. |
WeaponPrefs |
asGeneralOnly()
Return weapon preferences that has only "general" weapon preferences, might come in handy. |
void |
clearAllPrefs()
Removes all weapon preferences. |
protected WeaponPrefsRange |
getPreviousRange(WeaponPrefsRange weaponPrefsRange)
Get range that is right after "weaponPrefsRange". |
WeaponPref |
getWeaponPreference()
Return the best weapon according ONLY general preferences. |
WeaponPref |
getWeaponPreference(double distance)
Return the best weapon the bot has for a given distance (choosing right weapon preferances for a given distance). |
WeaponPref |
getWeaponPreference(double distance,
ItemType... forbiddenWeapons)
Return the best weapon the bot has for a given distance (choosing right weapon preferances for a given distance). |
WeaponPref |
getWeaponPreference(double distance,
WeaponPref... forbiddenWeapons)
Return the best weapon the bot has for a given distance (choosing right weapon preferances for a given distance). |
WeaponPref |
getWeaponPreference(ILocated target)
Return the best weapon the bot has to shoot at given location (choosing right weapon preferances for a given distance). |
WeaponPref |
getWeaponPreference(ILocated target,
ItemType... forbiddenWeapons)
Return the best weapon the bot has to shoot at given location (choosing right weapon preferances for a given distance). |
WeaponPref |
getWeaponPreference(ILocated target,
WeaponPref... forbiddenWeapons)
Return the best weapon the bot has to shoot at given location (choosing right weapon preferances for a given distance). |
WeaponPref |
getWeaponPreference(ItemType... forbiddenWeapons)
Return the best weapon according ONLY general preferences. |
WeaponPref |
getWeaponPreference(WeaponPref... forbiddenWeapons)
Return the best weapon according ONLY general preferences. |
WeaponPrefsRange |
getWeaponPreferences(double distance)
Get preferences for a given distance. |
WeaponPrefsRange |
newPrefsRange(double maxDistance)
Creates new WeaponPrefsRange , these weapon will be used when the target is at "maxDistance" afar. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List<WeaponPrefsRange> prefs
protected Weaponry weaponry
protected UT2004Bot bot
protected WeaponPrefsRange generalPrefs
protected WeaponPrefs onlyGeneral
Constructor Detail |
---|
public WeaponPrefs(Weaponry weaponry, UT2004Bot bot)
protected WeaponPrefs(Weaponry weaponry, UT2004Bot bot, WeaponPrefsRange generalPrefs)
Method Detail |
---|
public WeaponPrefs asGeneralOnly()
WARNING: returned prefs are IMMUTABLE! You can't invoke method newPrefsRange(double)
, addGeneralPref(ItemType, boolean)
or addGeneralPref(Weapon, boolean)
.
public void clearAllPrefs()
public WeaponPrefs addGeneralPref(ItemType weapon, boolean usePrimaryMode)
weapon
- weapon to be usedusePrimaryMode
- true == use primary firing mode, false == use secondary firing modepublic WeaponPrefs addGeneralPref(Weapon weapon, boolean usePrimaryMode)
weapon
- weapon to be usedusePrimaryMode
- true == use primary firing mode, false == use secondary firing modepublic WeaponPrefsRange newPrefsRange(double maxDistance)
WeaponPrefsRange
, these weapon will be used when the target is at "maxDistance" afar. Lower bound (minDistance)
is then define by previous WeaponPrefsRange object (if such exist, otherwise it is 0).
maxDistance
-
public WeaponPrefsRange getWeaponPreferences(double distance)
Distance may be negative == will choose only from the general preferences.
If no "ranges" are defined (no newPrefsRange(double)
has been used), it returns generalPrefs
.
distance
-
protected WeaponPrefsRange getPreviousRange(WeaponPrefsRange weaponPrefsRange)
weaponPrefsRange
-
public WeaponPref getWeaponPreference(double distance, ItemType... forbiddenWeapons)
May return null if "general preferences are not defined" or the bot does not have ammo to any of defined weapons.
Note that it may actually return "forbiddenWeapon" in the case that the bot does not have ammo for any other "more preferred" weapon but has ammo for some of forbiddenWeapon.
If distance < 0, only general preferences will be used.
distance
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
)
public WeaponPref getWeaponPreference(ILocated target, ItemType... forbiddenWeapons)
May return null if "general preferences are not defined" or the bot does not have ammo to any of defined weapons.
If target is null, only general preferences will be used.
target
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
)
public WeaponPref getWeaponPreference(ItemType... forbiddenWeapons)
forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. ItemType.ROCKET_LAUNCHER
)
public WeaponPref getWeaponPreference(double distance, WeaponPref... forbiddenWeapons)
May return null if "general preferences are not defined" or the bot does not have ammo to any of defined weapons.
Note that it may actually return "forbiddenWeapon" in the case that the bot does not have ammo for any other "more preferred" weapon but has ammo for some of forbiddenWeapon.
If distance < 0, only general preferences will be used.
distance
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose (i.e. WeaponPref#ROCKET_LAUNCHER
)
public WeaponPref getWeaponPreference(ILocated target, WeaponPref... forbiddenWeapons)
May return null if "general preferences are not defined" or the bot does not have ammo to any of defined weapons.
If target is null, only general preferences will be used.
target
- forbiddenWeapons
- optionally, you may define weapons which bot should not choose.
public WeaponPref getWeaponPreference(WeaponPref... forbiddenWeapons)
forbiddenWeapons
- optionally, you may define weapons which bot should not choose.
public WeaponPref getWeaponPreference(double distance)
May return null if "general preferences are not defined" or the bot does not have ammo to any of defined weapons.
If distance < 0, only general preferences will be used.
distance
-
public WeaponPref getWeaponPreference(ILocated target)
May return null if "general preferences are not defined" or the bot does not have ammo to any of defined weapons.
If target is null, only general preferences will be used.
target
-
public WeaponPref getWeaponPreference()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |