def add_skill_action(target, obj, **_): try: skill_name = target[0] except IndexError: raise ActionError("Skill name required") try: skill_level = int(target[1]) except (IndexError, ValueError): skill_level = 1 if ':' in skill_name: skill_id = skill_name else: skill_id = None for skill_type in dbo_types(SkillTemplate): if skill_name in fetch_set_keys(skill_type.dbo_set_key): skill_id = '{}:{}'.format(skill_type.dbo_key_type, skill_name) break if skill_id: skill_template = load_object(skill_id) if skill_template: add_skill(skill_template, obj, skill_level, 'immortal') if getattr(obj, 'dbo_id', None): save_object(obj) return "Added {} to {}".format(target, obj.name) return "Skill {} not found ".format(skill_name)
def main(self): constants = {key: config.get_value(key) for key in ['attributes', 'resource_pools', 'equip_types', 'equip_slots', 'weapon_types', 'damage_types', 'damage_delivery', 'damage_groups', 'affinities', 'imm_levels']} constants['weapon_options'] = constants['weapon_types'] + [{'dbo_id': 'unused'}, {'dbo_id': 'unarmed'}, {'dbo_id': 'any'}] constants['skill_calculation'] = constants['attributes'] + [{'dbo_id': 'roll', 'name': 'Dice Roll'}, {'dbo_id': 'skill', 'name': 'Skill Level'}] constants['defense_damage_types'] = constants['damage_types'] + constants['damage_groups'] constants['directions'] = Direction.ordered constants['article_load_types'] = ['equip', 'default'] constants['broadcast_types'] = broadcast_types constants['broadcast_tokens'] = broadcast_tokens constants['skill_types'] = [skill_template.dbo_key_type for skill_template in dbo_types(SkillTemplate)] constants['features'] = [get_dbo_class(feature_id)().edit_dto for feature_id in ['touchstone', 'entrance', 'store']] constants['shadow_types'] = ['any'] + list(implementors(Scriptable)) self._return(constants)
def _post_init(): context.set('skill_types', [skill_template.dbo_key_type for skill_template in dbo_types(SkillTemplate)])