Package horizons :: Package world :: Package units :: Module weaponholder :: Class WeaponHolder
[hide private]
[frames] | no frames]

Class WeaponHolder

source code

Instance Methods [hide private]
 
__init__(self, **kwargs) source code
 
__init(self) source code
 
remove(self) source code
 
create_weapon_storage(self) source code
 
update_range(self, caller=None) source code
 
_add_to_fireable(self, weapon)
Callback executed when weapon attack is ready
source code
 
_remove_from_fireable(self, weapon)
Callback executed when weapon is fired
source code
 
_increase_fired_weapons_number(self, caller=None)
Callback that helps keeping tack of successful weapon fire number
source code
 
add_weapon_to_storage(self, weapon_id)
adds weapon to storage
source code
 
remove_weapon_from_storage(self, weapon_id)
removes weapon to storage
source code
 
equip_from_inventory(self, weapon_id, number)
Equips weapon if present in inventory
source code
 
unequip_to_inventory(self, weapon_id, number)
Unequips weapon and adds it to inventory
source code
 
get_weapon_storage(self)
Returns storage object for self._weapon_storage
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
 
try_attack_target(self)
Attacking loop
source code
 
_stance_tick(self)
Executes every few seconds, doing movement depending on the stance.
source code
 
attack(self, target)
Triggers attack on target
source code
 
user_attack(self, targetid)
Called when the user triggeres the attack, executes the user_attack_issued callbacks
source code
 
is_attacking(self)
Returns True if the WeaponHolder is trying to attack a target
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
 
stop_attack(self) source code
 
fire_all_weapons(self, dest, rotated=False)
Fires all weapons in storage at a given position
source code
 
act_attack(self, dest)
Override in subclasses for action code
source code
 
get_attack_target(self) source code
 
save(self, db) source code
 
load_target(self, db)
Loads target from database
source code
 
load(self, db, worldid) source code
 
get_status(self)
Return the current status of the ship.
source code
Class Variables [hide private]
  log = logging.getLogger("world.combat")
Method Details [hide private]

add_weapon_to_storage(self, weapon_id)

source code 

adds weapon to storage

Parameters:
  • weapon_id - id of the weapon to be added

remove_weapon_from_storage(self, weapon_id)

source code 

removes weapon to storage

Parameters:
  • weapon_id - id of the weapon to be removed

equip_from_inventory(self, weapon_id, number)

source code 

Equips weapon if present in inventory

Parameters:
  • weapon_id - weapon id to be equipped
  • number - number of weapons to be equipped
Returns:
number of weapons that were not equipped

unequip_to_inventory(self, weapon_id, number)

source code 

Unequips weapon and adds it to inventory

Parameters:
  • weapon_id - weapon id to be unequipped
  • number - number of weapons to be unequipped
Returns:
number of weapons that were not added to storage

can_attack_position(self, position)

source code 

Returns True if the holder can attack position at call time

Parameters:
  • position - position of desired attack

_stance_tick(self)

source code 

Executes every few seconds, doing movement depending on the stance. Static WeaponHolders are aggressive, attacking all enemies that are in range

attack(self, target)

source code 

Triggers attack on target

Parameters:
  • target - target to be attacked

user_attack(self, targetid)

source code 

Called when the user triggeres the attack, executes the user_attack_issued callbacks

Parameters:
  • targetid - world id of the unit that is to be attacked

fire_all_weapons(self, dest, rotated=False)

source code 

Fires all weapons in storage at a given position

Parameters:
  • dest - Point with the given position
  • rotated - If True weapons will be fired at different locations, rotated around dest override to True for units that need to fire at rotated coords