Package horizons :: Package world :: Package units :: Module weapon :: Class Weapon
[hide private]
[frames] | no frames]

Class Weapon

source code


Generic Weapon class
it has the modifiers:
        damage - damage dealt in hp
        weapon_range - tuple with minimum and maximum attack range
        cooldown_time - number of seconds until the attack is ready again
        attack_speed - speed that calculates the time until attack reaches target
        attack_radius - radius affected by attack

        attack_ready callbacks are executed when the attack is made ready

Instance Methods [hide private]
 
__init__(self, session, id) source code
 
get_damage_modifier(self) source code
 
get_minimum_range(self) source code
 
get_maximum_range(self) source code
 
make_attack_ready(self) source code
 
fire(self, destination, position)
Fires the weapon at a certain destination
source code
 
check_target_in_range(self, distance)
Checks if the distance between the weapon and target is in weapon range
source code
 
get_ticks_until_ready(self)
Returns the number of ticks until the attack is ready If attack is ready return 0
source code
 
__str__(self) source code
Class Methods [hide private]
 
on_impact(cls, session, weapon_id, damage, position)
Classmethod that deals damage to units at position, depending on weapon_id Damage is done independent of the weapon instance, which may not exist at the time damage is done
source code
 
load_attacks(cls, session, db)
Loads ongoing attacks from savegame database Creates scheduled calls for on_impact
source code
 
save_attacks(cls, db)
Saves ongoing attacks
source code
Class Variables [hide private]
  log = logging.getLogger("world.combat")
Method Details [hide private]

__init__(self, session, id)
(Constructor)

source code 
Parameters:
  • session - game session
  • id - weapon id to be initialized

on_impact(cls, session, weapon_id, damage, position)
Class Method

source code 

Classmethod that deals damage to units at position, depending on weapon_id Damage is done independent of the weapon instance, which may not exist at the time damage is done

Parameters:
  • session - UH session
  • weapon_id - id of the weapon
  • damage - damage to be done
  • position - Point with position where damage needs to be done

fire(self, destination, position)

source code 

Fires the weapon at a certain destination

Parameters:
  • destination - Point with position where weapon will be fired
  • position - position where the weapon is fired from

check_target_in_range(self, distance)

source code 

Checks if the distance between the weapon and target is in weapon range

Parameters:
  • distance - distance between weapon and target