Exemple #1
0
    def __init__(self, gamedir, filename=None):

        self.attacks = list()
        self.x = 0
        self.y = 0
        self.radius = 0
        self.is_first_round = True
        GameObject.__init__(self, gamedir, filename)
Exemple #2
0
    def __init__(self, gamedir, projectiles, filename=None):

        self.attacks = list()
        self.defences = list()
        self.x = 0
        self.y = 0
        self.radius = 0
        self.is_first_round = True
        self.all_projectiles = projectiles
        self.projectile = None

        GameObject.__init__(self, gamedir, filename)
Exemple #3
0
    def __init__(self, globals, gamedir, filename = None):

        #
        self.gamedir = gamedir
        #
        # Global resources.
        #
        self.globals = globals
        #
        self.descriptions = list()
        #
        # objects and beings contain
        # actual game objects.
        #
        self.objects      = list()
        self.beings       = list()
        #
        # traps, weapons and monsters
        # only contain names (strings)
        # of things and not the actual
        # game objects.
        #
        self.traps        = list()
        self.weapons      = list()
        self.monsters     = list()
        #
        # links begins with strings
        # but the strings are replaced
        # with references to actual locations.
        #
        self.links        = dict()
        #
        # Sound(s) for this location.
        #
        self.sound_list   = list()
        self.num_sounds   = 0
        #
        #
        self.height = self.globals['screen_height']
        self.width  = self.globals['screen_width']

        GameObject.__init__(self, gamedir, filename)
Exemple #4
0
    def read_in_config(self, filename):

        parser = GameObject.read_in_config(self, filename)

        if parser.has_section('bio'):
            if parser.has_option('bio', 'projectile'):
                self.projectile = parser.get('bio', 'projectile')

                # Convert projectile string to real object.

                found = False
                for p in self.all_projectiles:
                    if self.projectile == p.name:
                        self.projectile = p
                        found = True
                if not found:
                    print "Warning: Projectile object could not be located for: %s" % self.projectile

        if parser.has_section('attacks'):
            self.attacks = mb_subs.actions(parser.items('attacks'))

        if parser.has_section('defences'):
            self.defences = mb_subs.actions(parser.items('defences'))
Exemple #5
0
    def __init__(self, gamedir, filename=None):
        """
        Create attributes that all monsters should have.

        """

        self.gamedir = gamedir

        # The following attributes are internal and are not
        # defined in the file.

        self.has_taunts = False
        self.total_damage = 0
        self.num_attacks = 0
        self.kills = 0
        self.percent_health = 100.0
        self.resurrections = 0
        self.parents = list()
        self.current_target = None
        self.current_weapon = None
        self.current_weapon_index = 0

        # This needs to go here and not with the weapon
        # otherwise, it causes some funny side-effects.
        self.weapon_pointing_angle = 0
        self.weapon_pointing_x = 0
        self.weapon_pointing_y = 0

        self.location = None
        self.x = 0
        self.y = 0
        self.radius = 25
        self.velocity = 0
        self.move_waypoint_x = None
        self.move_waypoint_y = None
        self.is_first_round = True

        # The attributes below can be specified in the monster file.

        self.family = None
        self.attacks = list()
        self.defences = list()
        self.fatalities = list()
        self.taunts = list()
        self.weapons = list()

        # These are the physical traits of the monster.
        # They are normalized or relative to an average
        # 180 lb 6 ft. athletic human.

        self.height = 1.0
        self.weight = 1.0
        self.agility = 1.0
        self.mobility = 1.0  # i.e. running/walking speed
        self.quickness = 1.0
        self.strength = 1.0
        self.jaw_strength = 1.0
        self.grip_strength = 1.0
        self.dexterity = 1.0
        self.intelligence = 1.0
        self.aggressiveness = 1.0
        self.weapon_ability = 1.0
        self.skin_strength = 1.0
        self.leaping_ability = 1.0

        # This is the default body makeup of the monster.

        self.heads = 1
        self.eyes = 2
        self.horns = 0
        self.arms = 2
        self.claws = 0
        self.legs = 2
        self.tails = 0

        # Default health

        self.health = 0

        # call init of parent object.  (is this necessary?)

        GameObject.__init__(self, self.gamedir, filename)
        self.originalName = self.name

        if filename is not None:
            self.read_in_config(filename)
Exemple #6
0
    def read_in_config(self, filename):

        parser = GameObject.read_in_config(self, filename)
        if parser.has_section('body'):

            if parser.has_option('body', 'heads'):
                self.heads = int(parser.get('body', 'heads'))
            if parser.has_option('body', 'eyes'):
                self.eyes = int(parser.get('body', 'eyes'))
            if parser.has_option('body', 'horns'):
                self.horns = int(parser.get('body', 'horns'))
            if parser.has_option('body', 'arms'):
                self.arms = int(parser.get('body', 'arms'))
            if parser.has_option('body', 'legs'):
                self.legs = int(parser.get('body', 'legs'))
            if parser.has_option('body', 'tails'):
                self.tails = int(parser.get('body', 'tails'))

        if parser.has_section('bio'):

            self.health = int(parser.get('bio', 'health'))

            if parser.has_option('bio', 'family'):
                self.family = parser.get('bio', 'family')

            if parser.has_option('bio', 'height'):
                self.height = float(parser.get('bio', 'height'))

            if parser.has_option('bio', 'weight'):
                self.weight = float(parser.get('bio', 'weight'))

            if parser.has_option('bio', 'agility'):
                self.agility = int(parser.get('bio', 'agility'))
            else:
                self.agility = 25

            if parser.has_option('bio', 'mobility'):
                self.mobility = float(parser.get('bio', 'mobility'))

            if parser.has_option('bio', 'quickness'):
                self.quickness = float(parser.get('bio', 'quickness'))

            if parser.has_option('bio', 'strength'):
                self.strength = float(parser.get('bio', 'strength'))

            if parser.has_option('bio', 'jaw_strength'):
                self.jaw_strength = float(parser.get('bio', 'jaw_strength'))

            if parser.has_option('bio', 'grip_strength'):
                self.grip_strength = float(parser.get('bio', 'grip_strength'))

            if parser.has_option('bio', 'dexterity'):
                self.dexterity = float(parser.get('bio', 'dexterity'))

            if parser.has_option('bio', 'intelligence'):
                self.intelligence = float(parser.get('bio', 'intelligence'))

            if parser.has_option('bio', 'aggressiveness'):
                self.aggressiveness = float(parser.get('bio',
                                                       'aggressiveness'))

            if parser.has_option('bio', 'weapon_ability'):
                self.weapon_ability = float(parser.get('bio',
                                                       'weapon_ability'))

            if parser.has_option('bio', 'skin_strength'):
                self.skin_strength = float(parser.get('bio', 'skin_strength'))

            if parser.has_option('bio', 'leaping_ability'):
                self.leaping_ability = float(
                    parser.get('bio', 'leaping_ability'))

            # Not ready to implement this yet.

            if parser.has_option('bio', 'weapons'):
                weapons_str = parser.get('bio', 'weapons')
                self.weapons = weapons_str.split(',')

        # end bio section.

        if parser.has_section('attacks'):
            self.attacks = mb_subs.actions(parser.items('attacks'))

        if parser.has_section('defences'):
            self.defences = mb_subs.actions(parser.items('defences'))

        if parser.has_section('fatalities'):
            self.fatalities = parser.options('fatalities')

        if parser.has_section('taunts'):
            self.taunts = parser.options('taunts')
            self.has_taunts = True

        return parser
Exemple #7
0
 def read_in_config(self, filename):
     parser = GameObject.read_in_config(self, filename)
     if parser.has_section('attacks'):
         self.attacks = mb_subs.actions(parser.items('attacks'))
     del parser