示例#1
0
def p_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        item_toTemplate = instance.item_templates[pReset.arg3]
    if pReset.arg2 > 50:  # old format */
        limit = 6
    elif pReset.arg2 == -1:  # no limit */
        limit = 999
    else:
        limit = pReset.arg2
    item_to = None
    item_to_list = instance.instances_by_item.get(item_toTemplate.vnum, None)
    if item_to_list:
        item_to = instance.global_instances[item_to_list[0]]

    if pArea.player_count > 0 \
            or not item_to \
            or (not item_to.in_room and not last) \
            or (itemTemplate.count >= limit and random.randint(0, 4) != 0) \
            or handler_item.count_obj_list(itemTemplate, item_to.inventory) > pReset.arg4:
        last = False
        return last, level, npc
    count = handler_item.count_obj_list(itemTemplate, item_to.inventory)
    #Converted while to For Loop, testing indicated
    #While loop was ~.002-.004
    #For loop ~.0009-.001
    if item_to:
        for i in range(pReset.arg4):
            item = object_creator.create_item(
                itemTemplate, game_utils.number_fuzzy(item_to.level))
            item_to.put(item)
            item = None
            count += 1
            if count >= pReset.arg4:
                break
            if itemTemplate.count >= limit:
                break

    # fix object lock state! */
        item_to.value[1] = item_toTemplate.value[1]
    last = True
    return last, level, npc
示例#2
0
文件: db.py 项目: carriercomm/PyRom
def p_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        item_toTemplate = instance.item_templates[pReset.arg3]
    if pReset.arg2 > 50:  # old format */
        limit = 6
    elif pReset.arg2 == -1:  # no limit */
        limit = 999
    else:
        limit = pReset.arg2
    item_to = None
    item_to_list = instance.instances_by_item.get(item_toTemplate.vnum, None)
    if item_to_list:
        item_to = instance.global_instances[item_to_list[0]]

    if pArea.player_count > 0 \
            or not item_to \
            or (not item_to.in_room and not last) \
            or (itemTemplate.count >= limit and random.randint(0, 4) != 0) \
            or handler_item.count_obj_list(itemTemplate, item_to.inventory) > pReset.arg4:
        last = False
        return last, level, npc
    count = handler_item.count_obj_list(itemTemplate, item_to.inventory)
    #Converted while to For Loop, testing indicated
    #While loop was ~.002-.004
    #For loop ~.0009-.001
    if item_to:
        for i in range(pReset.arg4):
            item = object_creator.create_item(itemTemplate, game_utils.number_fuzzy(item_to.level))
            item_to.put(item)
            item = None
            count += 1
            if count >= pReset.arg4:
                break
            if itemTemplate.count >= limit:
                break

    # fix object lock state! */
        item_to.value[1] = item_toTemplate.value[1]
    last = True
    return last, level, npc
示例#3
0
def o_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'O': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.room_templates.keys():
        logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg3][0]
        roomInstance = instance.global_instances[roomInstance_id]

    if pArea.player_count > 0 or handler_item.count_obj_list(
            itemTemplate, roomInstance.items) > 0:
        last = False
        return last, level, npc

    item = object_creator.create_item(
        itemTemplate, min(game_utils.number_fuzzy(level), merc.LEVEL_HERO - 1))
    item.cost = 0
    roomInstance.put(item)
    item = None
    last = True
    return last, level, npc
示例#4
0
文件: db.py 项目: carriercomm/PyRom
def o_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'O': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.room_templates.keys():
        logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg3][0]
        roomInstance = instance.global_instances[roomInstance_id]

    if pArea.player_count > 0 or handler_item.count_obj_list(itemTemplate, roomInstance.items) > 0:
        last = False
        return last, level, npc

    item = object_creator.create_item(itemTemplate, min(game_utils.number_fuzzy(level), merc.LEVEL_HERO - 1))
    item.cost = 0
    roomInstance.put(item)
    item = None
    last = True
    return last, level, npc
示例#5
0
def p_reset(parea, preset, last, level, npc):
    if preset.arg1 not in instance.item_templates.keys():
        comm.notify("p_reset: 'P': bad vnum {}".format(preset.arg1),
                    merc.CONSOLE_WARNING)
        return last, level, npc
    else:
        item_template = instance.item_templates[preset.arg1]

    if preset.arg3 not in instance.item_templates.keys():
        comm.notify("p_reset: 'P': bad vnum {}".format(preset.arg3),
                    merc.CONSOLE_WARNING)
        return last, level, npc
    else:
        item_to_template = instance.item_templates[preset.arg3]

    item_to = None
    item_to_list = instance.instances_by_item.get(item_to_template.vnum, None)
    if item_to_list:
        item_to = instance.global_instances[item_to_list[0]]

    if parea.player_count > 0 or not item_to or not item_to.in_room or handler_item.count_obj_list(
            item_template, item_to.inventory) > 0:
        last = False
        return last, level, npc

    item = object_creator.create_item(item_template,
                                      game_utils.number_range(1, 50))
    item_to.put(item)
    last = True
    return last, level, npc
示例#6
0
def o_reset(parea, preset, last, level, npc):
    if preset.arg1 not in instance.item_templates.keys():
        comm.notify("o_reset: 'O': bad vnum {}".format(preset.arg1),
                    merc.CONSOLE_WARNING)
        return last, level, npc
    else:
        item_template = instance.item_templates[preset.arg1]

    if preset.arg3 not in instance.room_templates.keys():
        comm.notify("o_reset: 'R': bad vnum {}".format(preset.arg3),
                    merc.CONSOLE_WARNING)
        return last, level, npc
    else:
        room_instance_id = instance.instances_by_room[preset.arg3][0]
        room_instance = instance.global_instances[room_instance_id]

    if parea.player_count > 0 or handler_item.count_obj_list(
            item_template, room_instance.items) > 0:
        last = False
        return last, level, npc

    item = object_creator.create_item(item_template,
                                      game_utils.number_range(1, 50))
    item.cost = 0
    room_instance.put(item)
    last = True
    return last, level, npc