Package pajammin :: Package ai :: Package script :: Module script :: Class Task
[show private | hide private]
[frames | no frames]

Type Task

object --+
         |
        Task

Known Subclasses:
AttackAvatar, AttackTarget, Defend, EndTask, FarieFollow, FireProjectileAt, Idle, Jump, JumpOff, LandOn, Say, UseMeleeAttack, WaitFor, WaitForAvatar, WalkAround, WalkPath, WalkToEntity, WalkToPos, WalkToX, WalkUpToEntity, Wander

A task that a script should attempt to accomplish. Subclasses of Task are used to define specific tasks.
Method Summary
  __init__(self)
  __repr__(self)
  act(self, level)
Attempt to accomplish this task, by examining and/or modifying the level; and should return a TaskResult object, indicating what action should be taken next.
  initialize(self, level)
This method is called when a script starts using this task.
  interrupt(self, level, condition, task_stack)
Attempt to accomplish this task, given that an interrupt condition occured.
  recover(self, level, failed_subtask, remaining_subtasks, failure_info)
Attempt to accomplish this task, given that a subtask failed.
  register(cls, *typesignature)
Register this task class as a task that can be used in the task list of a script. (Class method)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
Return hash(x)...
  __new__(T, S, ...)
Return a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
Return str(x)...

Instance Variable Summary
NoneType fail_task: A variable used to hold the task that should be notified if this task fails.
NoneType next_task: A variable used to hold the task that should be performed after this task.
NoneType timeout: If set to a value other than None, then this task will automatically fail if it has not finished before this amount of time (in msec) has elapsed.

Class Variable Summary
tuple interrupts = ()
NoneType require = None                                                                  
dict task_classes = {'WaitForAvatar': <class 'pajammin.ai.scr...
    Level Editor
NoneType signature: The type signature of this task.

Instance Method Details

__init__(self)
(Constructor)

Overrides:
__builtin__.object.__init__

__repr__(self)
(Representation operator)

Overrides:
__builtin__.object.__repr__

act(self, level)

Attempt to accomplish this task, by examining and/or modifying the level; and should return a TaskResult object, indicating what action should be taken next. See the class descriptions for the subclasses of TaskResult for information about the actions performed by each task.

Each time act() is called, it should only do a very small amount of work -- this will ensure that the game runs more smoothly.

initialize(self, level)

This method is called when a script starts using this task. It should initialize any instance variables used by the task. (Note that tasks can be reused, so this method may be called more than once.) By default, it does nothing.

interrupt(self, level, condition, task_stack)

Attempt to accomplish this task, given that an interrupt condition occured. This method is called if one of the task's interrupt conditions becomes true.

By default, interrupt() returns Failed().
Parameters:
condition - The interrupt condition that became true.
task_stack - A list containing the subtasks that were skipped because of this interrupt, and their interrupts. In principle, this could be used to resume...

recover(self, level, failed_subtask, remaining_subtasks, failure_info)

Attempt to accomplish this task, given that a subtask failed. This method is called if act() returns a DoFirst or DoInstead result (indicating that a list of subtasks should be performed), and one of those subtasks fails.

By default, recover() simply returns Failed().
Parameters:
failed_subtask - The subtask that failed
remaining_subtasks - The subtasks that followed the failed subtask; these were never tried.
failure_info - A string containing info about the cause of the failure.

Class Method Details

register(cls, *typesignature)

Register this task class as a task that can be used in the task list of a script. This will add it to the list task_classes, and will initialize its signature class variable. Tasks that register themselves are required to define instance variables corresponding to each of their constructor arguments (with the same names).
Parameters:
typesignature - The type signature of this task class's constructor. This signature should be a tuple of type names or of subclasses of Entity. In particular, the following values are recongized: 'string'; 'float'; 'pos'; 'rect'; and any subclass of Entity.

Instance Variable Details

fail_task

A variable used to hold the task that should be notified if this task fails. This variable should never be used or modified by the task itself; it is set and used by the Script class.
Type:
NoneType
Value:
None                                                                  

next_task

A variable used to hold the task that should be performed after this task. This variable should never be used or modified by the task itself; it is set and used by the Script class.
Type:
NoneType
Value:
None                                                                  

timeout

If set to a value other than None, then this task will automatically fail if it has not finished before this amount of time (in msec) has elapsed. (If a task has subtasks, then its timeout value will only be checked after all of the subtasks have returned.)
Type:
NoneType
Value:
None                                                                  

Class Variable Details

signature

The type signature of this task. This class variable is set by the class method register(), which registers this task for use with the level editor.
Type:
NoneType
Value:
None                                                                  

interrupts

Type:
tuple
Value:
()                                                                     

require

Type:
NoneType
Value:
None                                                                  

task_classes

Type:
dict
Value:
{'AttackAvatar': <class 'pajammin.ai.script.walker.AttackAvatar'>,
 'AttackTarget': <class 'pajammin.ai.script.walker.AttackTarget'>,
 'Defend': <class 'pajammin.ai.script.walker.Defend'>,
 'FarieFollow': <class 'pajammin.ai.script.farie.FarieFollow'>,
 'Idle': <class 'pajammin.ai.script.script.Idle'>,
 'Say': <class 'pajammin.ai.script.agent.Say'>,
 'WaitFor': <class 'pajammin.ai.script.agent.WaitFor'>,
 'WaitForAvatar': <class 'pajammin.ai.script.agent.WaitForAvatar'>,
...