|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread wyvern.kernel.commands.AbstractAI wyvern.kernel.monsters.StandardAI
The most common AI for game monsters. This AI is customizable via predicates and other properties, to produce interesting and even unique behavior for different monsters using the AI.
The properties by which it's currently customizable are as follows. Note that they're all properties on the monster, not on the AI. The AI itself has no properties to customize it.
Field Summary | |
static boolean |
DEBUG
|
static int |
MAX_RADIUS
Distance from a monster for which a player is considered to be "in range" (e.g. in view). |
Fields inherited from class wyvern.kernel.commands.AbstractAI |
commandables_, commandList_, queues_ |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface wyvern.lib.AI |
DEFAULT_MONSTER_INERTIA, DEFAULT_WANDER_RANGE |
Method Summary | |
static AI |
add(Commandable m)
Puts a monster under this AI's control. |
void |
addToHateList(Commandable defender,
Commandable attacker)
Adds the defender to the monster's I-hate-you list. |
boolean |
attackAdjacentPlayer(Commandable agent,
Commandable[] targets)
Looks for a player right next to us, so we can skip the search. |
boolean |
canWieldSomething(Commandable agent)
Returns true if the monster wants to wield a weapon. |
void |
debug(java.lang.String msg)
|
void |
emitMessages(Commandable agent,
java.lang.String temper)
Monster wants to speak its piece. |
boolean |
findPlayerToChase(Commandable agent,
Commandable[] targets)
Looks for a player nearby to move towards. |
static AI |
getImpl()
|
static AI |
getInstance()
|
Commandable[] |
getNearbyTargets(Commandable agent,
java.util.Set hates,
GameMap map)
Returns a list of the targets close enough to chase. |
static java.lang.String |
getProfilingInfo()
Returns info about monsters under our control. |
Commandable |
lineOfSight(Commandable monster,
Commandable[] targets)
Goes through the target list and looks for one with an unobstructed view, and returns it. |
boolean |
lookForObjects(Commandable monster,
GameMap map)
Looks for nice things to pick up. |
void |
notifyAttacked(Commandable defender,
Commandable attacker)
Notification that one of our monsters has been attacked. |
static void |
remove(Commandable m)
Removes a monster from our control. |
void |
setAppropriateBehavior(Commandable monster)
This function attempts to figure out which behavior to assign to a creature which doesn't currently have one. |
protected Point |
targetAdjacentMonster(Commandable monster,
Commandable target)
Looks for a player to target. |
void |
think(Commandable agent,
EventQueue q)
Decides what to do next. |
java.lang.String |
toString()
Returns a String representation. |
boolean |
tryAttackingWithoutMoving(Commandable agent,
Commandable[] targets)
Attempts to perform an attack without moving - useful for stationary monsters, but also the first thing to try for moving monsters, since it's cheaper than pathfinding. |
boolean |
tryCastSpell(Commandable monster,
Commandable[] targets,
boolean lineOfSight)
Attempts to cast a spell. |
boolean |
tryRangeWeapon(Commandable monster,
Commandable[] targets)
Attempts to fire a range weapon, throw something, use a wand or scroll, etc. instead of chasing a player. |
boolean |
tryStepBack(Commandable monster,
Commandable target)
In the specific case of a range-weapon-user or spellcaster that's adjacent to their target, we try to step away from the target. |
Methods inherited from class wyvern.kernel.commands.AbstractAI |
addCommandable, chooseRandomDir, getAverageTime, getCommand, getNumThinks, getTotalTime, isControlling, moveRandomly, registerCommand, removeCommandable, requestEvent, run, serviceQueues, thinkForQueue, unregisterCommand |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MAX_RADIUS
public static final boolean DEBUG
Method Detail |
public static AI getImpl()
public static AI getInstance()
public void setAppropriateBehavior(Commandable monster)
monster
- the critter that needs a behavior objectpublic static AI add(Commandable m)
m
- a monster to add
public static void remove(Commandable m)
m
- the monster to removepublic void think(Commandable agent, EventQueue q)
think
in interface AI
think
in class AbstractAI
agent
- the monster to think forq
- the monster's event queuepublic boolean tryAttackingWithoutMoving(Commandable agent, Commandable[] targets)
agent
- the monstertargets
- the list of possible target players/monsterspublic boolean tryRangeWeapon(Commandable monster, Commandable[] targets)
monster
- the monster that's lookingtargets
- the list of possible target monsters/players
public boolean tryCastSpell(Commandable monster, Commandable[] targets, boolean lineOfSight)
monster
- the monstertargets
- possible players to zaplineOfSight
- true to check if we have a clear path
to the player, false to cast in the direction of any player.
public boolean tryStepBack(Commandable monster, Commandable target)
monster
- the monstertarget
- the target
protected Point targetAdjacentMonster(Commandable monster, Commandable target)
monster
- the monstertarget
- the target player/monster
public boolean lookForObjects(Commandable monster, GameMap map)
monster
- the monster that's lookingmap
- the monster's mappublic final boolean attackAdjacentPlayer(Commandable agent, Commandable[] targets)
agent
- the monster lookingtargets
- the non-null, nonempty set of nearby targets
public boolean findPlayerToChase(Commandable agent, Commandable[] targets)
agent
- the monstertargets
- the non-null, nonempty set of nearby targets
public Commandable[] getNearbyTargets(Commandable agent, java.util.Set hates, GameMap map)
Normally looks for players, but if the monster has the "pet-monster" boolean property, it will look for monsters to attack instead, along with any players it's pissed off at.
agent
- the monsterhates
- a list of monsters or players we hate (e.g.
they attacked us), or null if n/a.map
- the monster's map
public boolean canWieldSomething(Commandable agent)
agent
- the monsterpublic void emitMessages(Commandable agent, java.lang.String temper)
agent
- the monstertemper
- the current AI temper of the monster; can be nullpublic Commandable lineOfSight(Commandable monster, Commandable[] targets)
monster
- the monster that wants to fire somethingtargets
- the list of potential targets
public void notifyAttacked(Commandable defender, Commandable attacker)
notifyAttacked
in interface AI
notifyAttacked
in class AbstractAI
defender
- the monster being attackedattacker
- the attacker (could be a monster or player)public void addToHateList(Commandable defender, Commandable attacker)
addToHateList
in interface AI
addToHateList
in class AbstractAI
public java.lang.String toString()
public void debug(java.lang.String msg)
public static java.lang.String getProfilingInfo()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |