wyvern.lib.ai.behaviors
Class Behavior

java.lang.Object
  extended bywyvern.lib.ai.behaviors.Behavior
Direct Known Subclasses:
AlwaysFleeBehavior, SimpleBehavior, StandardBehavior, StationaryBehavior

public class Behavior
extends java.lang.Object


Constructor Summary
Behavior(java.lang.String name)
           
 
Method Summary
 void add(BehaviorElement be)
           
 int getDistance(Point p1, Point p2)
           
 Commandable[] getNearbyTargets(Commandable agent, Predicate hatesThesePlayers, Predicate hatesTheseMonsters, java.util.Set hates)
          Returns a list of nearby targets close enough to chase and matching the appropriate predicate.
 void init()
           
 void setNearestReachable(Commandable agent, Commandable[] targets, java.lang.String name)
          Given a set of creatures, find the nearest one we can reach.
 void setNearestVisible(Commandable monster, Commandable[] targets, java.lang.String name)
          Given a set of creatures, find the nearest one we have a clear LOS to.
protected  Point targetAdjacentMonster(Commandable monster, Commandable target)
          Looks for a player to target.
 void think(Commandable agent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Behavior

public Behavior(java.lang.String name)
Method Detail

init

public void init()

add

public void add(BehaviorElement be)

think

public void think(Commandable agent)

setNearestVisible

public void setNearestVisible(Commandable monster,
                              Commandable[] targets,
                              java.lang.String name)
Given a set of creatures, find the nearest one we have a clear LOS to. Record it on the agent.

Parameters:
targets - the non-null, nonempty set of nearby targets
name - the name to use for the properties

setNearestReachable

public void setNearestReachable(Commandable agent,
                                Commandable[] targets,
                                java.lang.String name)
Given a set of creatures, find the nearest one we can reach. Record it on the agent.

Parameters:
agent - the monster
targets - the non-null, nonempty set of nearby targets
name - the name to use for the properties

getNearbyTargets

public Commandable[] getNearbyTargets(Commandable agent,
                                      Predicate hatesThesePlayers,
                                      Predicate hatesTheseMonsters,
                                      java.util.Set hates)
Returns a list of nearby targets close enough to chase and matching the appropriate predicate. Side effect: sets a property on the agent called "@a*-rect" containing the rectangle centered around the monster that it's willing to search. The internal names assume that it's looking for enemies, but it works for finding anything that matches a predicate.

Parameters:
agent - the monster
Returns:
a list of nearby targets, or null if none were found

targetAdjacentMonster

protected Point targetAdjacentMonster(Commandable monster,
                                      Commandable target)
Looks for a player to target. Works via side-effect: if we find a player adjacent to us, remembers the player (as a property) so we can fire in that direction later.

Parameters:
monster - the monster
target - the target player/monster
Returns:
a point to fire at if the target is adjacent

getDistance

public int getDistance(Point p1,
                       Point p2)