Ejemplo n.º 1
0
        return result

    @property
    def equips(self):
        """ Creature's equipment list.

        :returns: List of tuples containing equipment ID and :class:`pynwn.ItemInstance`.
        """
        result = []
        i = 0
        for p in self.gff['Equip_ItemList']:
            gff_inst = GffInstance(self.gff, 'Equip_ItemList', i)
            st_inst = ItemInstance(gff_inst, self.parent_obj)

            equip_slot = p['_STRUCT_TYPE_']
            result.append((equip_slot, st_inst))
            i += 1

        return result


for key, val in TRANSLATION_TABLE.items():
    setattr(Creature, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Creature, 'get_' + key, getter)
    setattr(Creature, 'set_' + key, setter)
Ejemplo n.º 2
0
        lbls[Event.ENTER] = "Mod_OnClientEntr"
        lbls[Event.EXIT] = "Mod_OnClientLeav"
        lbls[Event.HEARTBEAT] = "Mod_OnHeartbeat"
        lbls[Event.ITEM_ACQUIRED] = "Mod_OnAcquirItem"
        lbls[Event.ITEM_ACTIVATED] = "Mod_OnActvtItem"
        lbls[Event.ITEM_EQUIPPED] = "Mod_OnPlrEqItm"
        lbls[Event.ITEM_UNACQUIRED] = "Mod_OnUnAqreItem"
        lbls[Event.ITEM_UNEQUIPPED] = "Mod_OnPlrUnEqItm"
        lbls[Event.LEVELUP] = "Mod_OnPlrLvlUp"
        lbls[Event.LOAD] = "Mod_OnModLoad"
        lbls[Event.DEATH] = "Mod_OnPlrDeath"
        lbls[Event.DYING] = "Mod_OnPlrDying"
        lbls[Event.RESPAWN] = "Mod_OnSpawnBtnDn"
        lbls[Event.REST] = "Mod_OnPlrRest"
        lbls[Event.USER_DEFINED] = "Mod_OnUsrDefined"

        self._scripts = NWObjectScripts(self, lbls)

        return self._scripts


for key, val in TRANSLATION_TABLE.items():
    setattr(Module, key, make_gff_property("gff", val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property("gff", val)
    setattr(getter, "__doc__", val[1])
    setattr(setter, "__doc__", val[1])
    setattr(Module, "get_" + key, getter)
    setattr(Module, "set_" + key, setter)
Ejemplo n.º 3
0
        :returns: List of :class:`pynwn.StoreInstance` objects.
        """
        return self.get_instances('StoreList', StoreInstance)

    @property
    def triggers(self):
        """Triggers

        :returns: List of :class:`pynwn.TriggerInstance` objects.
        """
        return self.get_instances('TriggerList', TriggerInstance)

    @property
    def waypoints(self):
        """Waypoints

        :returns: List of :class:`pynwn.WaypointInstance` objects.
        """
        return self.get_instances('WaypointList', WaypointInstance)


for key, val in ARE_TRANSLATION_TABLE.items():
    setattr(Area, key, make_gff_property('are', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('are', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Area, 'get_' + key, getter)
    setattr(Area, 'set_' + key, setter)
Ejemplo n.º 4
0
class TriggerInstance(Trigger):
    """A trigger instance is one placed in an area in the toolset.
    As such it's values are derived from its parent GFF structure.
    """
    def __init__(self, gff, parent_obj):
        Trigger.__init__(self, gff, True)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        """Stages changes to parent GFF structure.
        """
        self.parent_obj.stage()

    @property
    def position(self):
        return (self.gff['XPosition'], self.gff['YPosition'],
                self.gff['ZPosition'])


for key, val in TRANSLATION_TABLE.items():
    setattr(Trigger, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Trigger, 'get_' + key, getter)
    setattr(Trigger, 'set_' + key, setter)
Ejemplo n.º 5
0
        result = []
        i = 0
        # If the creature doesn't have inventory items they won't
        # have an 'ItemList' field in their gff structure.
        try:
            for p in self.gff['ItemList']:
                gff_inst = GffInstance(self.gff, 'ItemList', i)
                st_inst = ItemInstance(gff_inst, self)
                repo_pos = (p['Repos_PosX'], p['Repos_Posy'])
                result.append((repo_pos, st_inst))
                i += 1
        except KeyError:
            pass

        return result

    @property
    def position(self):
        return self.gff['X'], self.gff['Y'], self.gff['Z']


for key, val in TRANSLATION_TABLE.items():
    setattr(Placeable, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Placeable, 'get_' + key, getter)
    setattr(Placeable, 'set_' + key, setter)
Ejemplo n.º 6
0
        if self.pointer == 'RepliesList':
            return self.parent.replies[i]
        else:
            return self.parent.entries[i]


DIALOG_PTR_TABLE = {
    'script': ('Active', 'Text appears when... script'),
    'index': ('Index', 'Index'),
    'comment': ('Comment', 'Comment'),
    'is_link': ('IsChild', 'Linked flag.'),
    'link_comment': ('LinkComment', 'Link comment.'),
}

for key, val in DIALOG_PTR_TABLE.items():
    setattr(DialogPointer, key, make_gff_property('gff', val))


class DialogNode(object):
    """Node in a dialog.

    These are distinguised internally by their pointer types.
    Entry nodes have reply pointers and vice-versa
    """
    def __init__(self, gff, pointer_type, parent):
        self.gff = gff
        self.pointer = pointer_type
        self.parent = parent

    @property
    def pointers(self):
Ejemplo n.º 7
0
    def level_stats(self):
        """ Player's level stat list.
        """
        result = []
        for p in self.gff["LvlStatList"]:
            ls = LevelStats()
            ls.class_type = p["LvlStatClass"].value
            ls.hitdice = p["LvlStatHitDie"].value
            ls.epic_level = p["EpicLevel"].value
            ls.skillpoints = p["SkillPoints"].value

            for sk in p["SkillList"]:
                ls.skills.append(sk["Rank"].value)

            for ft in p["FeatList"]:
                ls.feats.append(ft["Feat"].value)

            result.append(ls)
        return result


for key, val in TRANSLATION_TABLE.items():
    setattr(PlayerCharacter, key, make_gff_property("gff", val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property("gff", val)
    setattr(getter, "__doc__", val[1])
    setattr(setter, "__doc__", val[1])
    setattr(PlayerCharacter, "get_" + key, getter)
    setattr(PlayerCharacter, "set_" + key, setter)
Ejemplo n.º 8
0
        """
        res = []
        for page in self.gff['StoreList']:
            items = []
            i = 0
            try:
                for p in self.gff['ItemList']:
                    gff_inst = GffInstance(self.gff, 'ItemList', i)
                    st_inst = ItemInstance(gff_inst, self)
                    items.append(st_inst)
                    i += 1

            except Exception as e:
                print(e)
                pass

            res.append(items)

        return res


for key, val in TRANSLATION_TABLE.items():
    setattr(Store, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Store, 'get_' + key, getter)
    setattr(Store, 'set_' + key, setter)
Ejemplo n.º 9
0
        """
        res = []
        for page in self.gff['StoreList']:
            items = []
            i = 0
            try:
                for p in self.gff['ItemList']:
                    gff_inst = GffInstance(self.gff, 'ItemList', i)
                    st_inst = ItemInstance(gff_inst, self)
                    items.append(st_inst)
                    i += 1

            except Exception as e:
                print(e)
                pass

            res.append(items)

        return res


for key, val in TRANSLATION_TABLE.items():
    setattr(Store, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Store, 'get_' + key, getter)
    setattr(Store, 'set_' + key, setter)
Ejemplo n.º 10
0
    @property
    def sounds(self):
        return [s['Sound'] for s in self.gff['Sounds']]


class SoundInstance(Sound):
    """A sound instance is one placed in an area in the toolset.
    As such it's values are derived from its parent GFF structure.
    """
    def __init__(self, gff, parent_obj):
        Sound.__init__(self, gff, False)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        """Stages changes to parent GFF structure.
        """
        self.parent_obj.stage()


for key, val in TRANSLATION_TABLE.items():
    setattr(Sound, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Sound, 'get_' + key, getter)
    setattr(Sound, 'set_' + key, setter)
Ejemplo n.º 11
0
Archivo: area.py Proyecto: rmilne/pynwn
        :returns: List of StoreInstance objects.
        """
        return self.get_instances('StoreList', StoreInstance)

    @property
    def triggers(self):
        """Triggers

        :returns: List of TriggerInstance objects.
        """
        return self.get_instances('TriggerList', TriggerInstance)

    @property
    def waypoints(self):
        """Waypoints

        :returns: List of WaypointInstance objects.
        """
        return self.get_instances('WaypointList', WaypointInstance)

for key, val in ARE_TRANSLATION_TABLE.items():
    setattr(Area, key, make_gff_property('are', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('are', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Area, 'get_'+key, getter)
    setattr(Area, 'set_'+key, setter)
Ejemplo n.º 12
0
TRANSLATION_TABLE = {
    'id': ('Tile_ID', "ID."),
    'orientation': ('Tile_Orientation', "Orientation."),
    'height': ('Tile_Height', "Height."),
}


class TileInstance(object):
    """There is no base Tile class, Tiles can only be instances"""
    def __init__(self, gff, parent_obj):
        self.gff = gff
        self.is_intance = True
        self.parent_obj = parent_obj

    @property
    def main_lights(self):
        return self.gff['Tile_MainLight1'], self.gff['Tile_MainLight2']

    @property
    def source_lights(self):
        return self.gff['Tile_MainLight1'], self.gff['Tile_MainLight2']

    @property
    def anim_loops(self):
        return (self.gff['Tile_AnimLoop1'], self.gff['Tile_AnimLoop2'],
                self.gff['Tile_AnimLoop3'])


for key, val in TRANSLATION_TABLE.items():
    setattr(TileInstance, key, make_gff_property('gff', val))
Ejemplo n.º 13
0
class TriggerInstance(Trigger):
    """A trigger instance is one placed in an area in the toolset.
    As such it's values are derived from its parent GFF structure.
    """

    def __init__(self, gff, parent_obj):
        Trigger.__init__(self, gff, True)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        """Stages changes to parent GFF structure.
        """
        self.parent_obj.stage()

    @property
    def position(self):
        return (self.gff['XPosition'], self.gff['YPosition'],
                self.gff['ZPosition'])


for key, val in TRANSLATION_TABLE.items():
    setattr(Trigger, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Trigger, 'get_' + key, getter)
    setattr(Trigger, 'set_' + key, setter)
Ejemplo n.º 14
0
    """A door instance is one placed in an area in the toolset.
    As such it's values are derived from its parent GFF structure.
    """

    def __init__(self, gff, parent_obj):
        Door.__init__(self, gff, True)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        self.parent_obj.stage()

    @property
    def position(self):
        """Position

        :returns: Tuple of x, y, z coordinates.
        """
        return self.gff['X'], self.gff['Y'], self.gff['Z']


for key, val in TRANSLATION_TABLE.items():
    setattr(Door, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Door, 'get_' + key, getter)
    setattr(Door, 'set_' + key, setter)
Ejemplo n.º 15
0
    'orientation': ('Tile_Orientation', "Orientation."),
    'height': ('Tile_Height', "Height."),
}


class TileInstance(object):
    """There is no base Tile class, Tiles can only be instances"""

    def __init__(self, gff, parent_obj):
        self.gff = gff
        self.is_intance = True
        self.parent_obj = parent_obj

    @property
    def main_lights(self):
        return self.gff['Tile_MainLight1'], self.gff['Tile_MainLight2']

    @property
    def source_lights(self):
        return self.gff['Tile_MainLight1'], self.gff['Tile_MainLight2']

    @property
    def anim_loops(self):
        return (self.gff['Tile_AnimLoop1'],
                self.gff['Tile_AnimLoop2'],
                self.gff['Tile_AnimLoop3'])


for key, val in TRANSLATION_TABLE.items():
    setattr(TileInstance, key, make_gff_property('gff', val))
Ejemplo n.º 16
0
    def level_stats(self):
        """ Player's level stat list.
        """
        result = []
        for p in self.gff['LvlStatList']:
            ls = LevelStats()
            ls.class_type = p['LvlStatClass'].value
            ls.hitdice = p['LvlStatHitDie'].value
            ls.epic_level = p['EpicLevel'].value
            ls.skillpoints = p['SkillPoints'].value

            for sk in p['SkillList']:
                ls.skills.append(sk['Rank'].value)

            for ft in p['FeatList']:
                ls.feats.append(ft['Feat'].value)

            result.append(ls)
        return result


for key, val in TRANSLATION_TABLE.items():
    setattr(PlayerCharacter, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(PlayerCharacter, 'get_'+key, getter)
    setattr(PlayerCharacter, 'set_'+key, setter)
Ejemplo n.º 17
0
        self.parent_obj = parent_obj

    def stage(self):
        self.parent_obj.stage()

    @property
    def position(self):
        """Position in inventory

        :returns: Tuple of x and y coordinates.
        """
        return self.gff['Repos_PosX'], self.gff['Repos_Posy']


for key, val in REPO_TRANSLATION_TABLE.items():
    setattr(RepositoryItem, key, make_gff_property('gff', val))

IP_TRANSLATION_TABLE = {
    'type': ('PropertyName', 'Type.'),
    'subtype': ('Subtype', 'Subtype.'),
    'cost_table': ('CostTable', 'Cost table.'),
    'cost_value': ('CostValue', 'Cost value.'),
    'param_table': ('Param1', 'Parameter table.'),
    'param_value': ('Param1Value', 'Parameter value.'),
    'chance': ('ChanceAppear', 'Appearance chance.'),
}


class ItemProperty(object):
    def __init__(self, gff, parent_obj):
        self.gff = gff
Ejemplo n.º 18
0
        return result

    @property
    def equips(self):
        """ Creature's equipment list.

        :returns: List of tuples containing equipment ID and ItemInstance.
        """
        result = []
        i = 0
        for p in self.gff['Equip_ItemList']:
            gff_inst = GffInstance(self.gff, 'Equip_ItemList', i)
            st_inst  = ItemInstance(gff_inst, self.parent_obj)

            equip_slot = p['_STRUCT_TYPE_']
            result.append((equip_slot, st_inst))
            i += 1

        return result

for key, val in TRANSLATION_TABLE.items():
    setattr(Creature, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Creature, 'get_'+key, getter)
    setattr(Creature, 'set_'+key, setter)
Ejemplo n.º 19
0
        self.parent_obj = parent_obj
        self.is_instance = True

    def stage(self):
        self.parent_obj.stage()


ENC_CRE_TABLE = {
    'appearance': ('Appearance', 'Appearance'),
    'cr': ('CR', 'Challenge rating'),
    'resref': ('ResRef', 'Resref'),
    'unique': ('SingleSpawn', 'Unique spawn.')
}

for key, val in ENC_CRE_TABLE.items():
    setattr(EncounterCreature, key, make_gff_property('gff', val))

TRANSLATION_TABLE = {
    'tag': ('Tag', "Tag."),
    'resref': ('TemplateResRef', "Resref."),
    'active': ('Active', "Active flag."),
    'difficulty': ('Difficulty', "Difficulty."),
    'difficulty_index': ('DifficultyIndex', "Difficulty Index."),
    'faction': ('Faction', "Faction ID."),
    'max_creatures': ('MaxCreatures', "Maximum creatures."),
    'player_only': ('PlayerOnly', "Triggered by player only."),
    'rec_creatures': ('RecCreatures', "rec_creatures."),
    'reset': ('Reset', "Resets flag."),
    'reset_time': ('ResetTime', "Reset time."),
    'respawns': ('Respawns', "Respawns."),
    'spawn_option': ('SpawnOption', "Spawn option."),
Ejemplo n.º 20
0
Archivo: dialog.py Proyecto: jd28/pynwn
        if self.pointer == "RepliesList":
            return self.parent.replies[i]
        else:
            return self.parent.entries[i]


DIALOG_PTR_TABLE = {
    "script": ("Active", "Text appears when... script"),
    "index": ("Index", "Index"),
    "comment": ("Comment", "Comment"),
    "is_link": ("IsChild", "Linked flag."),
    "link_comment": ("LinkComment", "Link comment."),
}

for key, val in DIALOG_PTR_TABLE.items():
    setattr(DialogPointer, key, make_gff_property("gff", val))


class DialogNode(object):
    """Node in a dialog.

    These are distinguised internally by their pointer types.
    Entry nodes have reply pointers and vice-versa
    """

    def __init__(self, gff, pointer_type, parent):
        self.gff = gff
        self.pointer = pointer_type
        self.parent = parent

    @property
Ejemplo n.º 21
0
    @property
    def sounds(self):
        return [s['Sound'] for s in self.gff['Sounds']]


class SoundInstance(Sound):
    """A sound instance is one placed in an area in the toolset.
    As such it's values are derived from its parent GFF structure.
    """

    def __init__(self, gff, parent_obj):
        Sound.__init__(self, gff, False)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        """Stages changes to parent GFF structure.
        """
        self.parent_obj.stage()


for key, val in TRANSLATION_TABLE.items():
    setattr(Sound, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Sound, 'get_' + key, getter)
    setattr(Sound, 'set_' + key, setter)
Ejemplo n.º 22
0
Archivo: tile.py Proyecto: rmilne/pynwn
TRANSLATION_TABLE = {
    "id": ("Tile_ID", "ID."),
    "orientation": ("Tile_Orientation", "Orientation."),
    "height": ("Tile_Height", "Height."),
}


class TileInstance(object):
    """There is no base Tile class, Tiles can only be instances"""

    def __init__(self, gff, parent_obj):
        self.gff = gff
        self.is_intance = True
        self.parent_obj = parent_obj

    @property
    def main_lights(self):
        return (self.gff["Tile_MainLight1"], self.gff["Tile_MainLight2"])

    @property
    def source_lights(self):
        return (self.gff["Tile_MainLight1"], self.gff["Tile_MainLight2"])

    @property
    def anim_loops(self):
        return (self.gff["Tile_AnimLoop1"], self.gff["Tile_AnimLoop2"], self.gff["Tile_AnimLoop3"])


for key, val in TRANSLATION_TABLE.items():
    setattr(TileInstance, key, make_gff_property("gff", val))
Ejemplo n.º 23
0
            Event.EXIT: 'Mod_OnClientLeav',
            Event.HEARTBEAT: 'Mod_OnHeartbeat',
            Event.ITEM_ACQUIRED: 'Mod_OnAcquirItem',
            Event.ITEM_ACTIVATED: 'Mod_OnActvtItem',
            Event.ITEM_EQUIPPED: 'Mod_OnPlrEqItm',
            Event.ITEM_UNACQUIRED: 'Mod_OnUnAqreItem',
            Event.ITEM_UNEQUIPPED: 'Mod_OnPlrUnEqItm',
            Event.LEVELUP: 'Mod_OnPlrLvlUp',
            Event.LOAD: 'Mod_OnModLoad',
            Event.DEATH: 'Mod_OnPlrDeath',
            Event.DYING: 'Mod_OnPlrDying',
            Event.RESPAWN: 'Mod_OnSpawnBtnDn',
            Event.REST: 'Mod_OnPlrRest',
            Event.USER_DEFINED: 'Mod_OnUsrDefined'
        }

        self._scripts = NWObjectScripts(self, lbls)

        return self._scripts


for key, val in TRANSLATION_TABLE.items():
    setattr(Module, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Module, 'get_' + key, getter)
    setattr(Module, 'set_' + key, setter)
Ejemplo n.º 24
0
Archivo: door.py Proyecto: rmilne/pynwn
    """

    def __init__(self, gff, parent_obj):
        Door.__init__(self, gff, True)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        """Stages changes to the door instances parent object.
        """
        self.parent_obj.stage()

    @property
    def position(self):
        """Position

        :returns: Tuple of x, y, z coordinates.
        """
        return (self.gff["X"], self.gff["Y"], self.gff["Z"])


for key, val in TRANSLATION_TABLE.items():
    setattr(Door, key, make_gff_property("gff", val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property("gff", val)
    setattr(getter, "__doc__", val[1])
    setattr(setter, "__doc__", val[1])
    setattr(Door, "get_" + key, getter)
    setattr(Door, "set_" + key, setter)
Ejemplo n.º 25
0
        self.parent_obj = parent_obj

    def stage(self):
        self.parent_obj.stage()

    @property
    def position(self):
        """Position in inventory

        :returns: Tuple of x and y coordinates.
        """
        return self.gff['Repos_PosX'], self.gff['Repos_Posy']


for key, val in REPO_TRANSLATION_TABLE.items():
    setattr(RepositoryItem, key, make_gff_property('gff', val))

IP_TRANSLATION_TABLE = {
    'type': ('PropertyName', 'Type.'),
    'subtype': ('Subtype', 'Subtype.'),
    'cost_table': ('CostTable', 'Cost table.'),
    'cost_value': ('CostValue', 'Cost value.'),
    'param_table': ('Param1', 'Parameter table.'),
    'param_value': ('Param1Value', 'Parameter value.'),
    'chance': ('ChanceAppear', 'Appearance chance.'),
}


class ItemProperty(object):
    def __init__(self, gff, parent_obj):
        self.gff = gff
Ejemplo n.º 26
0
        result = []
        i = 0
        # If the creature doesn't have inventory items they won't
        # have an 'ItemList' field in their gff structure.
        try:
            for p in self.gff['ItemList']:
                gff_inst = GffInstance(self.gff, 'ItemList', i)
                st_inst = ItemInstance(gff_inst, self)
                repo_pos = (p['Repos_PosX'], p['Repos_Posy'])
                result.append((repo_pos, st_inst))
                i += 1
        except KeyError:
            pass

        return result

    @property
    def position(self):
        return self.gff['X'], self.gff['Y'], self.gff['Z']


for key, val in TRANSLATION_TABLE.items():
    setattr(Placeable, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Placeable, 'get_' + key, getter)
    setattr(Placeable, 'set_' + key, setter)
Ejemplo n.º 27
0
            return self._vars
        self._vars = NWObjectVarable(self, self.gff)
        return self._vars


class WaypointInstance(Waypoint):
    def __init__(self, gff, parent_obj):
        Waypoint.__init__(self, gff, True)
        self.parent_obj = parent_obj

    @property
    def position(self):
        return (self.gff['XPosition'], self.gff['YPosition'],
                self.gff['ZPosition'])

    def stage(self):
        """Stages changes to parent GFF structure.
        """
        self.parent_obj.stage()


for key, val in TRANSLATION_TABLE.items():
    setattr(Waypoint, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Waypoint, 'get_' + key, getter)
    setattr(Waypoint, 'set_' + key, setter)
Ejemplo n.º 28
0
    As such it's values are derived from its parent GFF structure.
    """
    def __init__(self, gff, parent_obj):
        Door.__init__(self, gff, True)
        self.is_instance = True
        self.parent_obj = parent_obj

    def stage(self):
        """Stages changes to the door instances parent object.
        """
        self.parent_obj.stage()

    @property
    def position(self):
        """Position

        :returns: Tuple of x, y, z coordinates.
        """
        return (self.gff['X'], self.gff['Y'], self.gff['Z'])


for key, val in TRANSLATION_TABLE.items():
    setattr(Door, key, make_gff_property('gff', val))

for key, val in LOCSTRING_TABLE.items():
    getter, setter = make_gff_locstring_property('gff', val)
    setattr(getter, '__doc__', val[1])
    setattr(setter, '__doc__', val[1])
    setattr(Door, 'get_' + key, getter)
    setattr(Door, 'set_' + key, setter)