def clone_item(parent, clone): if not parent or not clone: return # start fixing the object */ clone = handler_item.Items(parent) return clone
def load_objects(area, pArea): area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound while w != '0': flag_data = collections.namedtuple( 'item_flags', ('slots', 'restrictions', 'attributes', 'weapon')) flag_data.slots = set({}) flag_data.restrictions = set({}) flag_data.weapon = set({}) flag_data.attributes = set({}) item = handler_item.Items(None) item.vnum = int(w) instance.item_templates[item.vnum] = item item.area = pArea.name area, item.name = game_utils.read_string(area) area, item.short_descr = game_utils.read_string(area) area, item.description = game_utils.read_string(area) item.description = miniboa.terminal.escape(item.description, 'pyom') area, item.material = game_utils.read_string(area) area, item.item_type = game_utils.read_word(area, False) area, extra_bits = game_utils.read_flags(area) game_utils.item_flags_from_bits(extra_bits, flag_data, 'extra flags') area, wear_bits = game_utils.read_flags(area) game_utils.item_flags_from_bits(wear_bits, flag_data, 'wear flags') if merc.ITEM_LIGHT == item.item_type: flag_data.slots.update({'light'}) item.equips_to = flag_data.slots item.item_restrictions = flag_data.restrictions item.item_attributes = flag_data.attributes if item.item_type == merc.ITEM_WEAPON: area, item.value[0] = game_utils.read_word(area, False) area, item.value[1] = game_utils.read_int(area) area, item.value[2] = game_utils.read_int(area) area, item.value[3] = game_utils.read_word(area, False) item.value[3] = state_checks.name_lookup(const.attack_table, item.value[3]) area, item.value[4] = game_utils.read_flags(area) game_utils.item_flags_from_bits(item.value[4], flag_data, 'weapon flags') item.weapon_attributes = flag_data.weapon elif item.item_type == merc.ITEM_CONTAINER: area, item.value[0] = game_utils.read_int(area) area, item.value[1] = game_utils.read_flags(area) area, item.value[2] = game_utils.read_int(area) area, item.value[3] = game_utils.read_int(area) area, item.value[4] = game_utils.read_int(area) elif item.item_type == merc.ITEM_DRINK_CON or item.item_type == merc.ITEM_FOUNTAIN: area, item.value[0] = game_utils.read_int(area) area, item.value[1] = game_utils.read_int(area) area, item.value[2] = game_utils.read_word(area, False) area, item.value[3] = game_utils.read_int(area) area, item.value[4] = game_utils.read_int(area) elif item.item_type == merc.ITEM_WAND or item.item_type == merc.ITEM_STAFF: area, item.value[0] = game_utils.read_int(area) area, item.value[1] = game_utils.read_int(area) area, item.value[2] = game_utils.read_int(area) area, item.value[3] = game_utils.read_word(area, False) area, item.value[4] = game_utils.read_int(area) elif item.item_type == merc.ITEM_POTION or item.item_type == merc.ITEM_SCROLL \ or item.item_type == merc.ITEM_PILL: area, item.value[0] = game_utils.read_int(area) area, item.value[1] = game_utils.read_word(area, False) area, item.value[2] = game_utils.read_word(area, False) area, item.value[3] = game_utils.read_word(area, False) area, item.value[4] = game_utils.read_word(area, False) else: area, item.value[0] = game_utils.read_flags(area) area, item.value[1] = game_utils.read_flags(area) area, item.value[2] = game_utils.read_flags(area) area, item.value[3] = game_utils.read_flags(area) area, item.value[4] = game_utils.read_flags(area) area, item.level = game_utils.read_int(area) area, item.weight = game_utils.read_int(area) area, item.cost = game_utils.read_int(area) area, item.condition = game_utils.read_word(area, False) if item.condition == 'P': item.condition = 100 elif item.condition == 'G': item.condition = 90 elif item.condition == 'A': item.condition = 75 elif item.condition == 'W': item.condition = 50 elif item.condition == 'D': item.condition = 25 elif item.condition == 'B': item.condition = 10 elif item.condition == 'R': item.condition = 0 else: item.condition = 100 area, w = game_utils.read_word(area, False) while w == 'F' or w == 'A' or w == 'E': if w == 'F': area, word = game_utils.read_word(area, False) area, number = game_utils.read_int(area) area, number = game_utils.read_int(area) area, flags = game_utils.read_flags(area) elif w == 'A': paf = handler_game.AFFECT_DATA() paf.where = merc.TO_OBJECT paf.type = -1 paf.level = 20 paf.duration = -1 area, paf.location = game_utils.read_int(area) area, paf.modifier = game_utils.read_int(area) paf.bitvector = 0 item.affected += [paf] elif w == 'E': ed = world_classes.ExtraDescrData() area, ed.keyword = game_utils.read_string(area) area, ed.description = game_utils.read_string(area) item.extra_descr.append(ed) area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound return area
def load_objects(area, pArea): area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound while w != '0': obj = handler_item.Items() obj.vnum = int(w) instance.item_templates[obj.vnum] = obj area, obj.name = game_utils.read_string(area) area, obj.short_descr = game_utils.read_string(area) area, obj.description = game_utils.read_string(area) area, obj.material = game_utils.read_string(area) area, item_type = game_utils.read_word(area, False) area, obj.extra_flags = game_utils.read_flags(area) area, obj.wear_flags = game_utils.read_flags(area) obj.item_type = item_type if obj.item_type == merc.ITEM_WEAPON: area, obj.value[0] = game_utils.read_word(area, False) area, obj.value[1] = game_utils.read_int(area) area, obj.value[2] = game_utils.read_int(area) area, obj.value[3] = game_utils.read_word(area, False) obj.value[3] = state_checks.name_lookup(const.attack_table, obj.value[3]) area, obj.value[4] = game_utils.read_flags(area) elif obj.item_type == merc.ITEM_CONTAINER: area, obj.value[0] = game_utils.read_int(area) area, obj.value[1] = game_utils.read_flags(area) area, obj.value[2] = game_utils.read_int(area) area, obj.value[3] = game_utils.read_int(area) area, obj.value[4] = game_utils.read_int(area) elif obj.item_type == merc.ITEM_DRINK_CON or obj.item_type == merc.ITEM_FOUNTAIN: area, obj.value[0] = game_utils.read_int(area) area, obj.value[1] = game_utils.read_int(area) area, obj.value[2] = game_utils.read_word(area, False) area, obj.value[3] = game_utils.read_int(area) area, obj.value[4] = game_utils.read_int(area) elif obj.item_type == merc.ITEM_WAND or obj.item_type == merc.ITEM_STAFF: area, obj.value[0] = game_utils.read_int(area) area, obj.value[1] = game_utils.read_int(area) area, obj.value[2] = game_utils.read_int(area) area, obj.value[3] = game_utils.read_word(area, False) area, obj.value[4] = game_utils.read_int(area) elif obj.item_type == merc.ITEM_POTION or obj.item_type == merc.ITEM_SCROLL or obj.item_type == merc.ITEM_PILL: area, obj.value[0] = game_utils.read_int(area) area, obj.value[1] = game_utils.read_word(area, False) area, obj.value[2] = game_utils.read_word(area, False) area, obj.value[3] = game_utils.read_word(area, False) area, obj.value[4] = game_utils.read_word(area, False) else: area, obj.value[0] = game_utils.read_flags(area) area, obj.value[1] = game_utils.read_flags(area) area, obj.value[2] = game_utils.read_flags(area) area, obj.value[3] = game_utils.read_flags(area) area, obj.value[4] = game_utils.read_flags(area) area, obj.level = game_utils.read_int(area) area, obj.weight = game_utils.read_int(area) area, obj.cost = game_utils.read_int(area) area, obj.condition = game_utils.read_word(area, False) if obj.condition == 'P': obj.condition = 100 elif obj.condition == 'G': obj.condition = 90 elif obj.condition == 'A': obj.condition = 75 elif obj.condition == 'W': obj.condition = 50 elif obj.condition == 'D': obj.condition = 25 elif obj.condition == 'B': obj.condition = 10 elif obj.condition == 'R': obj.condition = 0 else: obj.condition = 100 area, w = game_utils.read_word(area, False) while w == 'F' or w == 'A' or w == 'E': if w == 'F': area, word = game_utils.read_word(area, False) area, number = game_utils.read_int(area) area, number = game_utils.read_int(area) area, flags = game_utils.read_flags(area) elif w == 'A': area, number = game_utils.read_int(area) area, number = game_utils.read_int(area) elif w == 'E': ed = world_classes.ExtraDescrData() area, ed.keyword = game_utils.read_string(area) area, ed.description = game_utils.read_string(area) obj.extra_descr.append(ed) area, w = game_utils.read_word(area, False) pArea.object_dict[obj.vnum] = obj w = w[1:] # strip the pound return area
def load_objects(area, parea): area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound while w != "0": vnum = int(w) if vnum in instance.item_templates: comm.notify("load_objects: vnum {} duplicated.".format(vnum), merc.CONSOLE_CRITICAL) sys.exit(1) flag_data = collections.namedtuple( "item_flags", ("slots", "restrictions", "attributes", "weapon")) flag_data.slots = set({}) flag_data.restrictions = set({}) flag_data.weapon = set({}) flag_data.attributes = set({}) item = handler_item.Items(None) item.vnum = vnum instance.item_templates[item.vnum] = item item.area = parea.name area, item.name = game_utils.read_string(area) area, item.short_descr = game_utils.read_string(area) item.short_descr = miniboa.terminal.escape(item.short_descr, "ANSI") area, item.description = game_utils.read_string(area) item.description = miniboa.terminal.escape(item.description, "ANSI") area, dummy = game_utils.read_string(area) area, item_type = game_utils.read_int(area) item_list = [(1, merc.ITEM_LIGHT), (2, merc.ITEM_SCROLL), (3, merc.ITEM_WAND), (4, merc.ITEM_STAFF), (5, merc.ITEM_WEAPON), (8, merc.ITEM_TREASURE), (9, merc.ITEM_ARMOR), (10, merc.ITEM_POTION), (12, merc.ITEM_FURNITURE), (15, merc.ITEM_CONTAINER), (17, merc.ITEM_DRINK_CON), (18, merc.ITEM_KEY), (19, merc.ITEM_FOOD), (20, merc.ITEM_MONEY), (22, merc.ITEM_BOAT), (23, merc.ITEM_CORPSE_NPC), (24, merc.ITEM_CORPSE_PC), (25, merc.ITEM_FOUNTAIN), (26, merc.ITEM_PILL), (27, merc.ITEM_PORTAL), (28, merc.ITEM_EGG), (29, merc.ITEM_VOODOO), (30, merc.ITEM_STAKE), (31, merc.ITEM_MISSILE), (32, merc.ITEM_AMMO), (33, merc.ITEM_QUEST), (34, merc.ITEM_QUESTCARD), (35, merc.ITEM_QUESTMACHINE), (36, merc.ITEM_SYMBOL), (37, merc.ITEM_BOOK), (38, merc.ITEM_PAGE), (39, merc.ITEM_TOOL)] for (aa, bb) in item_list: if item_type == aa: item.item_type = bb break else: item.item_type = merc.ITEM_TRASH area, extra_bits = game_utils.read_int(area) game_utils.item_flags_from_bits(extra_bits, flag_data, "extra flags") area, wear_bits = game_utils.read_int(area) game_utils.item_flags_from_bits(wear_bits, flag_data, "wear flags") if item.item_type == merc.ITEM_LIGHT: flag_data.slots.update({"right_hand", "left_hand"}) item.equips_to = flag_data.slots item.item_restrictions = flag_data.restrictions item.item_attributes = flag_data.attributes area, item.value[0] = game_utils.read_flags(area) area, item.value[1] = game_utils.read_flags(area) area, item.value[2] = game_utils.read_flags(area) area, item.value[3] = game_utils.read_flags(area) area, item.weight = game_utils.read_int(area) area, item.cost = game_utils.read_int(area) area, dummy = game_utils.read_int(area) area, w = game_utils.read_word(area, False) while w in ["A", "E", "Q"]: if w == "A": paf = handler_game.AffectData() paf.type = -1 paf.duration = -1 area, paf.location = game_utils.read_int(area) area, paf.modifier = game_utils.read_int(area) item.affected.append(paf) elif w == "E": edd = world_classes.ExtraDescrData() area, edd.keyword = game_utils.read_string(area) area, edd.description = game_utils.read_string(area) item.extra_descr.append(edd) elif w == "Q": area, item.chpoweron = game_utils.read_string(area) area, item.chpoweroff = game_utils.read_string(area) area, item.chpoweruse = game_utils.read_string(area) area, item.victpoweron = game_utils.read_string(area) area, item.victpoweroff = game_utils.read_string(area) area, item.victpoweruse = game_utils.read_string(area) area, sitem_bits = game_utils.read_flags(area) game_utils.item_flags_from_bits(sitem_bits, flag_data, "sitem flags") area, item.specpower = game_utils.read_int(area) area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound return area
def create_item(item_template, level, prev_instance_id: int = None): if not item_template: logger.critical("Create_object: No objTemplate.") sys.exit(1) item = handler_item.Items(item_template) if not prev_instance_id: pass # item.instancer() else: item.instance_id = prev_instance_id #item.instance_setup() #item.enchanted = False if item_template.new_format is False: item.level = max(0, level) if level == -1 or not item_template.new_format: item.cost = game_utils.number_fuzzy(10) * game_utils.number_fuzzy( level) * game_utils.number_fuzzy(level) # Mess with object properties. if item.item_type == merc.ITEM_LIGHT: if item.value[2] == 999: item.value[2] = -1 elif item.item_type == merc.ITEM_FURNITURE \ or item.item_type == merc.ITEM_TRASH \ or item.item_type == merc.ITEM_CONTAINER \ or item.item_type == merc.ITEM_DRINK_CON \ or item.item_type == merc.ITEM_KEY \ or item.item_type == merc.ITEM_FOOD \ or item.item_type == merc.ITEM_BOAT \ or item.item_type == merc.ITEM_CORPSE_NPC \ or item.item_type == merc.ITEM_CORPSE_PC \ or item.item_type == merc.ITEM_FOUNTAIN \ or item.item_type == merc.ITEM_MAP \ or item.item_type == merc.ITEM_CLOTHING \ or item.item_type == merc.ITEM_PORTAL: if not item_template.new_format: item.cost //= 5 elif item.item_type == merc.ITEM_TREASURE \ or item.item_type == merc.ITEM_WARP_STONE \ or item.item_type == merc.ITEM_ROOM_KEY \ or item.item_type == merc.ITEM_GEM \ or item.item_type == merc.ITEM_JEWELRY: pass elif item.item_type == merc.ITEM_JUKEBOX: item.value = [-1 for i in range(5)] elif item.item_type == merc.ITEM_SCROLL: if level != -1 and not item_template.new_format: item.value[0] = game_utils.number_fuzzy(item.value[0]) elif item.item_type == merc.ITEM_WAND \ or item.item_type == merc.ITEM_STAFF: if level != -1 and not item_template.new_format: item.value[0] = game_utils.number_fuzzy(item.value[0]) item.value[1] = game_utils.number_fuzzy(item.value[1]) item.value[2] = item.value[1] if not item_template.new_format: item.cost *= 2 elif item.item_type == merc.ITEM_WEAPON: if level != -1 and not item_template.new_format: item.value[1] = game_utils.number_fuzzy( game_utils.number_fuzzy(1 * level // 4 + 2)) item.value[2] = game_utils.number_fuzzy( game_utils.number_fuzzy(3 * level // 4 + 6)) elif item.item_type == merc.ITEM_ARMOR: if level != -1 and not item_template.new_format: item.value[0] = game_utils.number_fuzzy(level // 5 + 3) item.value[1] = game_utils.number_fuzzy(level // 5 + 3) item.value[2] = game_utils.number_fuzzy(level // 5 + 3) elif item.item_type == merc.ITEM_POTION \ or item.item_type == merc.ITEM_PILL: if level != -1 and not item_template.new_format: item.value[0] = game_utils.number_fuzzy( game_utils.number_fuzzy(item.value[0])) elif item.item_type == merc.ITEM_MONEY: if not item_template.new_format: item.value[0] = item.cost else: logger.error("Bad item_type objTemplate vnum: %s(%s)" % (item_template.vnum, item.item_type)) #for paf in item_template.affected: # if paf.location == merc.APPLY_SPELL_AFFECT: # item.affect_add(paf) return item
def create_item(item_template, level, prev_instance_id: int = None): if not item_template: comm.notify("create_item: no item_template", merc.CONSOLE_INFO) sys.exit(1) item = handler_item.Items(item_template) if not prev_instance_id: pass # item.instancer() else: item.instance_id = prev_instance_id item.level = level if item.vnum in merc.irange(29500, 29599): item.flags.artifact = True item.condition = 100 item.toughness = 100 item.resistance = 1 item.level = 60 item.cost = 1000000 elif item.vnum in merc.irange(29600, 29699): item.flags.relic = True item.condition = 100 item.toughness = 100 item.resistance = 1 else: item.condition = 100 item.toughness = 5 item.resistance = 25 # Mess with object properties. if item.item_type == merc.ITEM_SCROLL: item.value[0] = game_utils.number_fuzzy(item.value[0]) elif item.item_type in [merc.ITEM_WAND, merc.ITEM_STAFF]: item.value[0] = game_utils.number_fuzzy(item.value[0]) item.value[1] = game_utils.number_fuzzy(item.value[1]) item.value[2] = item.value[1] elif item.item_type == merc.ITEM_WEAPON: if not item.flags.artifact and not item.flags.relic: item.value[1] = game_utils.number_range(1, 10) item.value[2] = game_utils.number_range(item.value[1] + 1, item.value[1] * 2) elif item.item_type == merc.ITEM_ARMOR: if not item.flags.artifact and not item.flags.relic: item.value[0] = game_utils.number_range(5, 15) elif item.item_type in [merc.ITEM_POTION, merc.ITEM_PILL]: item.value[0] = game_utils.number_fuzzy( game_utils.number_fuzzy(item.value[0])) elif item.item_type == merc.ITEM_MONEY: item.value[0] = item.cost elif item.item_type in [ merc.ITEM_LIGHT, merc.ITEM_TREASURE, merc.ITEM_FURNITURE, merc.ITEM_TRASH, merc.ITEM_CONTAINER, merc.ITEM_DRINK_CON, merc.ITEM_KEY, merc.ITEM_FOOD, merc.ITEM_BOAT, merc.ITEM_CORPSE_NPC, merc.ITEM_CORPSE_PC, merc.ITEM_FOUNTAIN, merc.ITEM_PORTAL, merc.ITEM_EGG, merc.ITEM_VOODOO, merc.ITEM_STAKE, merc.ITEM_MISSILE, merc.ITEM_AMMO, merc.ITEM_QUEST, merc.ITEM_QUESTCARD, merc.ITEM_QUESTMACHINE, merc.ITEM_SYMBOL, merc.ITEM_BOOK, merc.ITEM_PAGE, merc.ITEM_TOOL ]: pass else: comm.notify( "create_item: bad item_type {} ({})".format( item_template.vnum, item.item_type), merc.CONSOLE_WARNING) item_template.count += 1 return item