Package horizons :: Package component :: Module stancecomponent :: Class LimitedMoveStance
[hide private]
[frames] | no frames]

Class LimitedMoveStance

source code

  Component --+    
              |    
StanceComponent --+
                  |
                 LimitedMoveStance


Stance that attacks any unit in stance range and follows it with limited move space
This is inherited by Aggressive and Hold Ground stances
In adition to StanceComponent it has the following attributes:
        stance_radius - int with the radius in which instance shold look for target
        move_range - int with the radius in which instance shold move when attacking it
It also keeps track of the return position in which the unit should return when stopped attacking

Instance Methods [hide private]
 
__init__(self)
Used for initialization code that does not require any other components.
source code
 
get_instance_data(self) source code
 
act_idle(self)
Find target in range then attack it
source code
 
act_user_move(self)
At the end of user move change the returning position
source code
 
act_user_attack(self)
If attack ends, update the returning position
source code
 
act_move_back(self)
When moving back try to find target.
source code
 
act_auto_attack(self)
Check if target still exists or if unit exited the hold ground area
source code
 
get_target(self, radius)
Returns closest attackable unit in radius
source code
    Inherited from StanceComponent
 
act(self)
Act according to current state This is called every few second in the instance code
source code
 
act_flee(self)
Method executed when the instance is trying to evade an attack
source code
 
get_state(self) source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
remove(self)
Removes component and reference to instance
source code
 
set_state(self, state) source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
 
session(self) source code
Class Methods [hide private]
    Inherited from Component
 
get_instance(cls, arguments=None)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
    Inherited from StanceComponent
  NAME = 'stance'
hash(x)
    Inherited from Component
  DEPENDENCIES = []
Method Details [hide private]

__init__(self)
(Constructor)

source code 

Used for initialization code that does not require any other components. This is always called first, on construction and on load.

Overrides: Component.__init__
(inherited documentation)

act_idle(self)

source code 

Find target in range then attack it

Overrides: StanceComponent.act_idle

act_user_move(self)

source code 

At the end of user move change the returning position

Overrides: StanceComponent.act_user_move

act_user_attack(self)

source code 

If attack ends, update the returning position

Overrides: StanceComponent.act_user_attack

act_move_back(self)

source code 

When moving back try to find target. If found, attack it and drop movement

Overrides: StanceComponent.act_move_back

act_auto_attack(self)

source code 

Check if target still exists or if unit exited the hold ground area

Overrides: StanceComponent.act_auto_attack