def parse_links_items_rewards(): logging.debug('Parsing Maps <> Items (Rewards)...') ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies.ipf', 'map.ies') with open(ies_path, 'rb') as ies_file: for row in csv.DictReader(ies_file, delimiter=',', quotechar='"'): if int(row['MapRatingRewardCount1']) == 0 or len(row['MapRatingRewardItem1']) == 0: continue item = globals.get_item_link(row['MapRatingRewardItem1']).entity item_link = globals.get_item_link(row['MapRatingRewardItem1']) item_link = { 'Chance': 100, 'Item': item_link, 'Quantity_MAX': int(row['MapRatingRewardCount1']), 'Quantity_MIN': int(row['MapRatingRewardCount1']), } map = globals.maps_by_name[row['ClassName']] map_link = globals.get_map_link(map['$ID_NAME']) map_link = { 'Chance': 100, 'Map': map_link, 'Quantity_MAX': int(row['MapRatingRewardCount1']), 'Quantity_MIN': int(row['MapRatingRewardCount1']), } globals.link( map, 'Link_Items_Exploration', map_link, item, 'Link_Maps_Exploration', item_link )
def parse_links_items(): logging.debug('Parsing items for recipes...') ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies.ipf', 'recipe.ies') ies_file = open(ies_path, 'rb') ies_reader = csv.DictReader(ies_file, delimiter=',', quotechar='"') for row in ies_reader: recipe = globals.recipes_by_name[row['ClassName']] recipe['Link_Target'] = globals.get_item_link(row['TargetItem']) recipe['Name'] = 'Recipe - Unknown' if recipe['Link_Target'] is not None: recipe['Name'] = 'Recipe - ' + recipe['Link_Target']['Name'] # Parse ingredients for i in range(1, 6): if row['Item_' + str(i) + '_1'] == '': continue obj = {} obj['Item'] = globals.get_item_link(row['Item_' + str(i) + '_1']) obj['Quantity'] = int(row['Item_' + str(i) + '_1_Cnt']) recipe['Link_Materials'].append(obj) ies_file.close()
def parse_links_items(): logging.debug('Parsing items for collections...') ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies.ipf', 'collection.ies') ies_file = open(ies_path, 'rb') ies_reader = csv.DictReader(ies_file, delimiter=',', quotechar='"') for row in ies_reader: if row['ClassName'] not in globals.collections_by_name: continue collection = globals.collections_by_name[row['ClassName']] # Parse items for i in range(1, 10): item_name = row['ItemName_' + str(i)] if item_name == '': continue collection['Link_Items'].append(globals.get_item_link(item_name)) # Parse bonus bonus = row['PropList'].split('/') + row['AccPropList'].split('/') bonus = filter(lambda x: len(x) > 0, bonus) for i in range(0, len(bonus), 2): collection['Bonus'].append([ parse_links_items_bonus_stat(bonus[i]), # Property int(bonus[i + 1]) # Value ]) ies_file.close()
def parse_links_drops(): logging.debug('Parsing drops for monsters...') for id_monster in globals.monsters: monster = globals.monsters[id_monster] file_name = monster['$ID_NAME'] + '.ies' try: ies_path = os.path.join(constants.PATH_INPUT_DATA, "ies_drop.ipf", file_name.lower()) ies_file = open(ies_path, 'rb') ies_reader = csv.DictReader(ies_file, delimiter=',', quotechar='"') # logging.debug('Parsing monster: %s :: %s', monster['$ID'], monster['$ID_NAME']) for row in ies_reader: obj = {} obj['Chance'] = int(row['DropRatio']) / 100.0 obj['Item'] = globals.get_item_link(row['ItemClassName']) obj['Quantity_MAX'] = int(row['Money_Max']) obj['Quantity_MIN'] = int(row['Money_Min']) monster['Link_Drops'].append(obj) ies_file.close() except IOError: continue
def parse_links_items(): logging.debug('Parsing Monsters <> Items...') for monster in globals.monsters.values(): ies_file = monster['$ID_NAME'] + '.ies' ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies_drop.ipf', ies_file.lower()) try: with open(ies_path, 'rb') as ies_file: for row in csv.DictReader(ies_file, delimiter=',', quotechar='"'): if not row['ItemClassName'] or globals.get_item_link( row['ItemClassName']) is None: continue item = globals.get_item_link(row['ItemClassName']).entity item_link = globals.get_item_link(item) item_link = { 'Chance': int(row['DropRatio']) / 100.0, 'Item': item_link, 'Quantity_MAX': int(row['Money_Max']), 'Quantity_MIN': int(row['Money_Min']), } monster_link = globals.get_monster_link(monster) monster_link = { 'Chance': int(row['DropRatio']) / 100.0, 'Monster': monster_link, 'Quantity_MAX': int(row['Money_Max']), 'Quantity_MIN': int(row['Money_Min']), } globals.link(monster, 'Link_Items', monster_link, item, 'Link_Monsters', item_link) except IOError: continue
def parse_links_items(): logging.debug('Parsing items for cubes...') ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies.ipf', 'reward_indun.ies') ies_file = open(ies_path, 'rb') ies_reader = csv.DictReader(ies_file, delimiter=',', quotechar='"') for row in ies_reader: if row['Group'] not in globals.cubes_by_stringarg: continue cube = globals.cubes_by_stringarg[row['Group']] cube['Link_Items'].append(globals.get_item_link(row['ItemName'])) ies_file.close()
def parse_links_items(file_name): logging.debug('Parsing items for equipment sets: %s...', file_name) ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies.ipf', file_name) ies_file = open(ies_path, 'rb') ies_reader = csv.DictReader(ies_file, delimiter=',', quotechar='"') for row in ies_reader: equipment_set = globals.equipment_sets_by_name[row['ClassName']] # Parse items for i in range(1, 8): item_name = row['ItemName_' + str(i)] if item_name == '': continue item = globals.get_item_link(item_name) if item is not None: equipment_set['Link_Items'].append(item) ies_file.close()
def parse_links_npcs(): logging.debug('Parsing Maps <> NPCs...') ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies.ipf', 'map.ies') with open(ies_path, 'rb') as ies_file: for row in csv.DictReader(ies_file, delimiter=',', quotechar='"'): map = globals.maps_by_name[row['ClassName']] map_offset_x = int(round(int(row['Width']) / 2.0)) map_offset_y = int(round(int(row['Height']) / 2.0)) anchors = {} # Spawn Positions (aka Anchors) ies_file = 'anchor_' + map['$ID_NAME'] + '.ies' ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies_mongen.ipf', ies_file.lower()) try: with open(ies_path, 'rb') as ies_file: for row in csv.DictReader(ies_file, delimiter=',', quotechar='"'): obj = anchors[row['GenType']] if row['GenType'] in anchors else { 'Anchors': [], 'GenType': {} } obj['Anchors'].append([ int((map_offset_x + float(row['PosX'])) * MAP_SCALE), int((map_offset_y - float(row['PosZ'])) * MAP_SCALE), ]) anchors[row['GenType']] = obj except IOError: continue # Spawn NPCs ies_file = 'gentype_' + map['$ID_NAME'] + '.ies' ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies_mongen.ipf', ies_file.lower()) try: with open(ies_path, 'rb') as ies_file: for row in csv.DictReader(ies_file, delimiter=',', quotechar='"'): if globals.get_npc_link(row['ClassType']) is None: continue if row['GenType'] not in anchors: continue obj = anchors[row['GenType']] obj['GenType'] = row except IOError: continue # Group by Item/NPC and join anchors anchors_by_npc = {} for anchor in anchors.values(): if len(anchor['GenType'].keys()) == 0: continue item_name = re.search('\w+:(\w+):\w+', anchor['GenType']['ArgStr2']) npc_name = item_name.group(1) if item_name else anchor['GenType']['ClassType'] if npc_name in anchors_by_npc: anchors_by_npc[npc_name]['Anchors'] += anchor['Anchors'] anchors_by_npc[npc_name]['GenType']['MaxPop'] = int(anchors_by_npc[npc_name]['GenType']['MaxPop']) + int(anchor['GenType']['MaxPop']) else: anchors_by_npc[npc_name] = anchor # Link everyone for anchor_name in anchors_by_npc.keys(): anchor = anchors_by_npc[anchor_name] if globals.get_item_link(anchor_name): item = globals.get_item_link(anchor_name).entity item_link = globals.get_item_link(item['$ID_NAME']) item_link = { 'Item': item_link, 'Population': int(anchor['GenType']['MaxPop']), 'Positions': anchor['Anchors'], 'TimeRespawn': int(anchor['GenType']['RespawnTime']) / 1000.0, } map_link = globals.get_map_link(map['$ID_NAME']) map_link = { 'Chance': 100, 'Map': map_link, 'Quantity_MAX': 1, 'Quantity_MIN': 1, } globals.link( map, 'Link_NPCs', map_link, item, 'Link_Maps', item_link ) elif globals.get_npc_link(anchor_name): map_link = globals.get_map_link(map['$ID_NAME']) map_link = { 'Map': map_link, 'Population': int(anchor['GenType']['MaxPop']), 'TimeRespawn': int(anchor['GenType']['RespawnTime']) / 1000.0, } npc = globals.get_npc_link(anchor_name).entity npc_link = globals.get_npc_link(npc['$ID_NAME']) npc_link = { 'NPC': npc_link, 'Population': int(anchor['GenType']['MaxPop']), 'Positions': anchor['Anchors'], 'TimeRespawn': int(anchor['GenType']['RespawnTime']) / 1000.0, } globals.link( map, 'Link_NPCs', map_link, npc, 'Link_Maps', npc_link )
def parse_links_items(): logging.debug('Parsing Maps <> Items...') for map in globals.maps.values(): ies_file = 'zonedropitemlist_' + map['$ID_NAME'] + '.ies' ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies_drop.ipf', 'zonedrop', ies_file.lower()) # For some reason IMC uses these 2 types of name formats... if not os.path.isfile(ies_path): ies_file = 'zonedropitemlist_f_' + map['$ID_NAME'] + '.ies' ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies_drop.ipf', 'zonedrop', ies_file.lower()) try: drops = [] with open(ies_path, 'rb') as ies_file: for zone_drop in csv.DictReader(ies_file, delimiter=',', quotechar='"'): if len(zone_drop['ItemClassName']) > 0: drops.append({ 'ItemClassName': zone_drop['ItemClassName'], 'DropRatio': int(zone_drop['DropRatio']) / 100.0, 'Money_Max': int(zone_drop['Money_Max']), 'Money_Min': int(zone_drop['Money_Min']), }) # Note: drop groups work like a loot table # Therefore we need to sum the DropRatio of the entire group before calculating the actual one if len(zone_drop['DropGroup']) > 0: ies_file = zone_drop['DropGroup'] + '.ies' ies_path = os.path.join(constants.PATH_INPUT_DATA, 'ies_drop.ipf', 'dropgroup', ies_file.lower()) group_drop_ratio = 0 group_drops = [] with open(ies_path, 'rb') as ies_file: for group_drop in csv.DictReader(ies_file, delimiter=',', quotechar='"'): group_drop_ratio += int(group_drop['DropRatio']) group_drops.append({ 'ItemClassName': group_drop['ItemClassName'], 'DropRatio': int(group_drop['DropRatio']), 'Money_Max': 0, 'Money_Min': 0, }) for group_drop in group_drops: group_drop['DropRatio'] = int(zone_drop['DropRatio']) / 100.0 * group_drop['DropRatio'] / group_drop_ratio drops.append(group_drop) for drop in drops: item_link = { 'Chance': drop['DropRatio'], 'Item': globals.get_item_link(drop['ItemClassName']), 'Quantity_MAX': drop['Money_Max'], 'Quantity_MIN': drop['Money_Min'], } map_link = { 'Chance': drop['DropRatio'], 'Map': globals.get_map_link(map['$ID_NAME']), 'Quantity_MAX': drop['Money_Max'], 'Quantity_MIN': drop['Money_Min'], } globals.link( map_link['Map'].entity, 'Link_Items', map_link, item_link['Item'].entity, 'Link_Maps', item_link ) except IOError: continue