Package horizons :: Package world :: Package units :: Module groundunit :: Class FightingGroundUnit
[hide private]
[frames] | no frames]

Class FightingGroundUnit

source code

                         weaponholder.WeaponHolder --+    
                                                     |    
                       weaponholder.MovingWeaponHolder --+
                                                         |
 component.componentholder.ComponentHolder --+           |
                                             |           |
util.changelistener.ChangeListener --+       |           |
                                     |       |           |
          util.worldobject.WorldObject --+   |           |
                                         |   |           |
             concreteobject.ConcreteObject --+           |
                                             |           |
                     movingobject.MovingObject --+       |
                                                 |       |
       resourcehandler.ResourceTransferHandler --+       |
                                                 |       |
                                         unit.Unit --+   |
                                                     |   |
                                            GroundUnit --+
                                                         |
                                                        FightingGroundUnit

Weapon Holder Ground Unit

Instance Methods [hide private]
 
__init__(self, x, y, **kwargs) source code
 
go(self, x, y) source code
 
act_attack(self, dest)
Rotates to target and acts correctly
source code
    Inherited from weaponholder.MovingWeaponHolder
 
_move_and_attack(self, destination, not_possible_action=None, in_range_callback=None)
Callback for moving to a destination, then attack
source code
 
_stance_tick(self)
Executes every few seconds, doing movement depending on the stance.
source code
 
load(self, db, worldid) source code
 
save(self, db) source code
 
set_stance(self, stance)
Sets the stance to a specific one and passes the current state
source code
 
stop_for(self, ticks)
Delays movement for a number of ticks.
source code
 
try_attack_target(self)
Attacking loop
source code
 
user_attack(self, targetid)
Called when the user triggeres the attack, executes the user_attack_issued callbacks
source code
    Inherited from weaponholder.WeaponHolder
 
_add_to_fireable(self, weapon)
Callback executed when weapon attack is ready
source code
 
_increase_fired_weapons_number(self, caller=None)
Callback that helps keeping tack of successful weapon fire number
source code
 
_remove_from_fireable(self, weapon)
Callback executed when weapon is fired
source code
 
add_weapon_to_storage(self, weapon_id)
adds weapon to storage
source code
 
attack(self, target)
Triggers attack on target
source code
 
attack_in_range(self)
Returns True if the target is in range, False otherwise
source code
 
can_attack_position(self, position)
Returns True if the holder can attack position at call time
source code
 
create_weapon_storage(self) source code
 
equip_from_inventory(self, weapon_id, number)
Equips weapon if present in inventory
source code
 
fire_all_weapons(self, dest, rotated=False)
Fires all weapons in storage at a given position
source code
 
get_attack_target(self) source code
 
get_status(self)
Return the current status of the ship.
source code
 
get_weapon_storage(self)
Returns storage object for self._weapon_storage
source code
 
is_attacking(self)
Returns True if the WeaponHolder is trying to attack a target
source code
 
load_target(self, db)
Loads target from database
source code
 
remove(self) source code
 
remove_target(self)
Removes reference from target, this happens when the attack is stopped or the target is dead either way the refs are checked using gc module this is used because after unit death it's possbile that it still has refs
source code
 
remove_weapon_from_storage(self, weapon_id)
removes weapon to storage
source code
 
stop_attack(self) source code
 
unequip_to_inventory(self, weapon_id, number)
Unequips weapon and adds it to inventory
source code
 
update_range(self, caller=None) source code
    Inherited from GroundUnit
 
_move_tick(self, resume=False)
Called by the scheduler, moves the unit one step for this tick.
source code
    Inherited from unit.Unit
 
__str__(self) source code
 
_on_damage(self, caller=None)
Called when health has changed
source code
 
classname(self) source code
 
draw_health(self, remove_only=False, auto_remove=False)
Draws the units current health as a healthbar over the unit.
source code
 
get_random_location(self, in_range)
Returns a random location in walking_range, that we can find a path to Does not check every point, only a few samples are tried.
source code
 
hide(self)
Hides the unit.
source code
 
onInstanceActionCancelled(self, instance, action) source code
 
onInstanceActionFinished(self, instance, action) source code
 
show(self) source code
    Inherited from movingobject.MovingObject
 
_movement_finished(self) source code
 
_setup_move(self, action='move')
Executes necessary steps to begin a movement.
source code
 
add_blocked_callback(self, blocked_callback)
Registers callback to be executed when movement of the unit gets blocked.
source code
 
add_conditional_callback(self, condition, callback)
Adds a callback, that gets called, if, at any time of the movement, the condition becomes True.
source code
 
add_move_callback(self, callback)
Registers callback to be executed when movement of unit finishes.
source code
 
check_move(self, destination)
Tries to find a path to destination
source code
 
get_move_target(self) source code
 
get_unit_velocity(self)
Returns the number of ticks that it takes to do a straight (i.e.
source code
 
is_moving(self)
Returns whether unit is currently moving
source code
 
move(self, destination, callback=None, destination_in_building=False, action='move', blocked_callback=None, path=None)
Moves unit to destination
source code
 
stop(self, callback=None)
Stops a unit with currently no possibility to continue the movement.
source code
 
teleport(self, destination, callback=None, destination_in_building=False)
Like move, but nearly instantaneous
source code
    Inherited from component.componentholder.ComponentHolder
 
add_component(self, component)
Adds new component to holder and sets the instance attribute on the component
source code
 
get_component(self, component) source code
 
get_component_by_name(self, name) source code
 
has_component(self, component_class)
Check if holder has component with component name
source code
 
initialize(self, **kwargs)
Has to be called every time a componentholder is created.
source code
 
remove_component(self, component_class)
Removes component from holder.
source code
    Inherited from concreteobject.ConcreteObject
 
act(self, action, facing_loc=None, repeating=False, force_restart=True) source code
 
fife_instance(self) source code
 
has_action(self, action)
Checks if this unit has a certain action.
source code
 
name(self) source code
    Inherited from util.worldobject.WorldObject
 
__lt__(self, other) source code
    Inherited from util.changelistener.ChangeListener
 
_changed(self)
Calls every listener when an object changed
source code
 
add_change_listener(self, listener, call_listener_now=False, no_duplicates=False) source code
 
add_remove_listener(self, listener, no_duplicates=False)
A listener that listens for removal of the object
source code
 
clear_change_listeners(self)
Removes all change listeners
source code
 
discard_change_listener(self, listener)
Remove listener if it's there
source code
 
discard_remove_listener(self, listener) source code
 
end(self) source code
 
has_change_listener(self, listener) source code
 
has_remove_listener(self, listener) source code
 
remove_change_listener(self, listener) source code
 
remove_remove_listener(self, listener) source code
    Inherited from resourcehandler.ResourceTransferHandler
 
transfer_to_storageholder(self, amount, res_id, transfer_to, signal_errors=False)
Transfers amount of res_id to transfer_to.
source code
Class Methods [hide private]
    Inherited from component.componentholder.ComponentHolder
 
get_component_template(cls, component)
Returns the component template data given a component NAME
source code
    Inherited from concreteobject.ConcreteObject
 
get_random_action_set(cls, level=0, exact_level=False)
Returns an action set for an object of type object_id in a level <= the specified level.
source code
 
weighted_choice(cls, weighted_dict)
http://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/
source code
    Inherited from util.worldobject.WorldObject
 
get_object_by_id(cls, id)
Returns the worldobject with id id Throws WorldObjectNotFound with the worldid as arg.
source code
 
get_objs(cls) source code
 
reset(cls) source code
Class Variables [hide private]
    Inherited from weaponholder.WeaponHolder
  log = logging.getLogger("world.combat")
    Inherited from GroundUnit
  health_bar_y = -70
  pather_class = SoldierPather
hash(x)
    Inherited from unit.Unit
  AUTOMATIC_HEALTH_DISPLAY_TIMEOUT = 10
  is_ship = False
  is_unit = True
    Inherited from movingobject.MovingObject
  movable = True
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
    Inherited from concreteobject.ConcreteObject
  is_building = False
Method Details [hide private]

__init__(self, x, y, **kwargs)
(Constructor)

source code 
Parameters:
  • x - int x position
  • y - int y position
Overrides: util.changelistener.ChangeListener.__init__

go(self, x, y)

source code 
Overrides: unit.Unit.go

act_attack(self, dest)

source code 

Rotates to target and acts correctly

Overrides: weaponholder.WeaponHolder.act_attack