示例#1
0
def d_reset(pReset, last, level, npc):
    if pReset.arg1 not in instance.room_templates.keys():
        logger.error("Reset_area: 'D': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg1][0]
        roomInstance = instance.global_instances[roomInstance_id]
        pexit = roomInstance.exit[pReset.arg2]
    if not pexit:
        return last, level, npc

    if pReset.arg3 == 0:
        pexit.exit_info = state_checks.REMOVE_BIT(pexit.exit_info,
                                                  merc.EX_CLOSED)
        pexit.exit_info = state_checks.REMOVE_BIT(pexit.exit_info,
                                                  merc.EX_LOCKED)
        return last, level, npc
    elif pReset.arg3 == 1:
        pexit.exit_info = state_checks.SET_BIT(pexit.exit_info, merc.EX_CLOSED)
        pexit.exit_info = state_checks.REMOVE_BIT(pexit.exit_info,
                                                  merc.EX_LOCKED)
        return last, level, npc
    elif pReset.arg3 == 2:
        pexit.exit_info = state_checks.SET_BIT(pexit.exit_info, merc.EX_CLOSED)
        pexit.exit_info = state_checks.SET_BIT(pexit.exit_info, merc.EX_LOCKED)
        return last, level, npc
    last = True
    return last, level, npc
示例#2
0
def do_close(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Close what?\n")
        return

    # TODO: Verify this section after equipment revamp
    obj = ch.get_item_here(arg)
    if obj:
        # portal stuff */
        if obj.item_type == merc.ITEM_PORTAL:
            if not state_checks.IS_SET(obj.value[1], merc.EX_ISDOOR) or state_checks.IS_SET(obj.value[1],
                                                                                            merc.EX_NOCLOSE):
                ch.send("You can't do that.\n")
                return
            if state_checks.IS_SET(obj.value[1], merc.EX_CLOSED):
                ch.send("It's already closed.\n")
                return
            obj.value[1] = state_checks.SET_BIT(obj.value[1], merc.EX_CLOSED)
            handler_game.act("You close $p.", ch, obj, None, merc.TO_CHAR)
            handler_game.act("$n closes $p.", ch, obj, None, merc.TO_ROOM)
            return
        # 'close object' */
        if obj.item_type != merc.ITEM_CONTAINER:
            ch.send("That's not a container.\n")
            return
        if state_checks.IS_SET(obj.value[1], merc.CONT_CLOSED):
            ch.send("It's already closed.\n")
            return
        if not state_checks.IS_SET(obj.value[1], merc.CONT_CLOSEABLE):
            ch.send("You can't do that.\n")
            return
        obj.value[1] = state_checks.SET_BIT(obj.value[1], merc.CONT_CLOSED)
        handler_game.act("You close $p.", ch, obj, None, merc.TO_CHAR)
        handler_game.act("$n closes $p.", ch, obj, None, merc.TO_ROOM)
        return
    door = handler_room.find_door(ch, arg)
    if handler_room.find_door(ch, arg) >= 0:
        # 'close door'
        pexit = ch.in_room.exit[door]
        if pexit.exit_info.is_set(merc.EX_CLOSED):
            ch.send("It's already closed.\n")
            return
        pexit.exit_info.set_bit(merc.EX_CLOSED)
        handler_game.act("$n closes the $d.", ch, None, pexit.keyword, merc.TO_ROOM)
        ch.send("Ok.\n")

        # close the other side
        to_room = instance.rooms[pexit.to_room]
        pexit_rev = to_room.exit[merc.rev_dir[door]] if pexit.to_room else None
        if to_room and pexit_rev and pexit_rev.to_room == ch.in_room.instance_id:
            pexit_rev.exit_info.set_bit(merc.EX_CLOSED)
            for rch_id in to_room.people[:]:
                rch = instance.characters[rch_id]
                handler_game.act("The $d closes.", rch, None, pexit_rev.keyword, merc.TO_CHAR)
示例#3
0
def do_wiznet(ch, argument):
    if not argument:
        if state_checks.IS_SET(ch.wiznet, merc.WIZ_ON):
            ch.send("Signing off of Wiznet.\n")
            ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, merc.WIZ_ON)
        else:
            ch.send("Welcome to Wiznet!\n")
            ch.wiznet = state_checks.SET_BIT(ch.wiznet, merc.WIZ_ON)
        return

    if "on".startswith(argument):
        ch.send("Welcome to Wiznet!\n")
        ch.wiznet = state_checks.SET_BIT(ch.wiznet, merc.WIZ_ON)
        return
    if "off".startswith(argument):
        ch.send("Signing off of Wiznet.\n")
        ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, merc.WIZ_ON)
        return
    buf = ''
    # show wiznet status
    if "status".startswith(argument):
        if not state_checks.IS_SET(ch.wiznet, merc.WIZ_ON):
            buf += "off "
        for name, flag in const.wiznet_table.items():
            if state_checks.IS_SET(ch.wiznet, flag.bit):
                buf += name + " "
            ch.send("Wiznet status:\n%s\n" % buf)
            return
    if "show".startswith(argument):
        # list of all wiznet options
        buf = ''
        for name, flag in const.wiznet_table.items():
            if flag.level <= ch.trust:
                buf += name + " "
        ch.send("Wiznet options available to you are:\n%s\n" % buf)
        return
    flag = state_checks.prefix_lookup(const.wiznet_table, argument)
    if not flag or ch.trust < flag.level:
        ch.send("No such option.\n")
        return
    if state_checks.IS_SET(ch.wiznet, flag.bit):
        ch.send("You will no longer see %s on wiznet.\n" % flag.name)
        ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, flag.bit)
        return
    else:
        ch.send("You will now see %s on wiznet.\n" % flag.name)
        ch.wiznet = state_checks.SET_BIT(ch.wiznet, flag.bit)
        return
示例#4
0
def do_notell(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Notell whom?")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    if victim.comm.is_set(merc.COMM_NOTELL):
        victim.comm = state_checks.REMOVE_BIT(victim.comm, merc.COMM_NOTELL)
        victim.send("You can tell again.\n")
        ch.send("NOTELL removed.\n")
        handler_game.wiznet("$N restores tells to %s." % victim.name, ch, None,
                            merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    else:
        victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_NOTELL)
        victim.send("You can't tell!\n")
        ch.send("NOTELL set.\n")
        handler_game.wiznet("$N revokes %s's tells." % victim.name, ch, None,
                            merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    return
示例#5
0
def do_freeze(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Freeze whom?\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.is_npc():
        ch.send("Not on NPC's.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    if victim.act.is_set(merc.PLR_FREEZE):
        victim.act.rem_bit(merc.PLR_FREEZE)
        victim.send("You can play again.\n")
        ch.send("FREEZE removed.\n")
        handler_game.wiznet("$N thaws %s." % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    else:
        state_checks.SET_BIT(victim.act, merc.PLR_FREEZE)
        victim.send("You can't do ANYthing!\n")
        ch.send("FREEZE set.\n")
        handler_game.wiznet("$N puts %s in the deep freeze." % victim.name, ch, None, merc.WIZ_PENALTIES,
                            merc.WIZ_SECURE, 0)

    victim.save(force=True)
    return
示例#6
0
def do_nochannels(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Nochannel whom?")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    if victim.comm.is_set(merc.COMM_NOCHANNELS):
        victim.comm = state_checks.REMOVE_BIT(victim.comm,
                                              merc.COMM_NOCHANNELS)
        victim.send("The gods have restored your channel priviliges.\n")
        ch.send("NOCHANNELS removed.\n")
        handler_game.wiznet("$N restores channels to %s" % victim.name, ch,
                            None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    else:
        victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_NOCHANNELS)
        victim.send("The gods have revoked your channel priviliges.\n")
        ch.send("NOCHANNELS set.\n")
        handler_game.wiznet("$N revokes %s's channels." % victim.name, ch,
                            None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    return
示例#7
0
def do_noshout(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Noshout whom?\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.is_npc():
        ch.send("Not on NPC's.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    if victim.comm.is_set(merc.COMM_NOSHOUT):
        victim.comm = state_checks.REMOVE_BIT(victim.comm, merc.COMM_NOSHOUT)
        victim.send("You can shout again.\n")
        ch.send("NOSHOUT removed.\n")
        handler_game.wiznet("$N restores shouts to %s." % victim.name, ch,
                            None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    else:
        victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_NOSHOUT)
        victim.send("You can't shout!\n")
        ch.send("NOSHOUT set.\n")
        handler_game.wiznet("$N revokes %s's shouts." % victim.name, ch, None,
                            merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    return
示例#8
0
文件: do_log.py 项目: totalgit/PyRom
def do_log(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Log whom?\n")
        return
    if arg == "all":
        #TODO: fix this by either adding it to merc, or figuring out an alternative
        if fLogAll:
            fLogAll = False
            ch.send("Log ALL off.\n")
        else:
            fLogAll = True
            ch.send("Log ALL on.\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.is_npc():
        ch.send("Not on NPC's.\n")
        return
    # No level check, gods can log anyone.
    if victim.act.is_set(merc.PLR_LOG):
        victim.act = victim.act.rem_bit(merc.PLR_LOG)
        ch.send("LOG removed.\n")
    else:
        victim.act = state_checks.SET_BIT(victim.act, merc.PLR_LOG)
        ch.send("LOG set.\n")
    return
示例#9
0
def do_nosummon(ch, argument):
    if ch.is_npc():
        if state_checks.IS_SET(ch.imm_flags, merc.IMM_SUMMON):
            ch.send("You are no longer immune to summon.\n")
            ch.imm_flags = state_checks.REMOVE_BIT(ch.imm_flags,
                                                   merc.IMM_SUMMON)
        else:
            ch.send("You are now immune to summoning.\n")
            ch.imm_flags = state_checks.SET_BIT(ch.imm_flags, merc.IMM_SUMMON)
    else:
        if ch.act.is_set(merc.PLR_NOSUMMON):
            ch.send("You are no longer immune to summon.\n")
            ch.act.rem_bit(merc.PLR_NOSUMMON)
        else:
            ch.send("You are now immune to summoning.\n")
            ch.act.set_bit(merc.PLR_NOSUMMON)
示例#10
0
def do_protect(ch, argument):
    if not argument:
        ch.send("Protect whom from snooping?\n")
        return
    victim = ch.get_char_world(argument)
    if not victim:
        ch.send("You can't find them.\n")
        return
    if victim.comm.is_set(merc.COMM_SNOOP_PROOF):
        handler_game.act("$N is no longer snoop-proof.", ch, None, victim,
                         merc.TO_CHAR, merc.POS_DEAD)
        victim.send("Your snoop-proofing was just removed.\n")
        victim.comm = state_checks.REMOVE_BIT(victim.comm,
                                              merc.COMM_SNOOP_PROOF)
    else:
        handler_game.act("$N is now snoop-proof.", ch, None, victim,
                         merc.TO_CHAR, merc.POS_DEAD)
        victim.send("You are now immune to snooping.\n")
        victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_SNOOP_PROOF)
示例#11
0
def do_clantalk(ch, argument):
    if not ch.is_clan() or ch.clan.independent:
        ch.send("You aren't in a clan.\n")
        return
    if not argument:
        if state_checks.IS_SET(ch.comm, merc.COMM_NOCLAN):
            ch.send("Clan channel is now ON\n")
            ch.comm = state_checks.REMOVE_BIT(ch.comm, merc.COMM_NOCLAN)
        else:
            ch.send("Clan channel is now OFF\n")
            ch.comm = state_checks.SET_BIT(ch.comm, merc.COMM_NOCLAN)
        return
    if state_checks.IS_SET(ch.comm, merc.COMM_NOCHANNELS):
        ch.send("The gods have revoked your channel priviliges.\n")
        return
    ch.comm = state_checks.REMOVE_BIT(ch.comm, merc.COMM_NOCLAN)

    ch.send("You clan '%s'\n" % argument)
    for d in merc.descriptor_list:
        if d.is_connected(nanny.con_playing) and d.character != ch and ch.is_same_clan(d.character) \
                and not state_checks.IS_SET(d.character.comm, merc.COMM_NOCLAN) and not state_checks.IS_SET(d.character.comm,
                                                                                            merc.COMM_QUIET):
            merc.act("$n clans '$t'", ch, argument, d.character, merc.TO_VICT,
                     merc.POS_DEAD)
示例#12
0
def do_deny(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Deny whom?\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.is_npc():
        ch.send("Not on NPC's.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    victim.act = state_checks.SET_BIT(victim.act, merc.PLR_DENY)
    victim.send("You are denied access!\n")
    handler_game.wiznet("$N denies access to %s" % victim.name, ch, None,
                        merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    ch.send("OK.\n")
    victim.save(logout=True, force=True)
    fight.stop_fighting(victim, True)
    victim.do_quit("")
    return
示例#13
0
def spell_enchant_weapon(sn, level, ch, victim, target):
    obj = victim

    if obj.item_type != merc.ITEM_WEAPON:
        ch.send("That isn't a weapon.\n")
        return

    if obj.wear_loc != -1:
        ch.send("The item must be carried to be enchanted.\n")
        return

    # this means they have no bonus */
    hit_bonus = 0
    dam_bonus = 0
    fail = 25  # base 25% chance of failure */
    dam_found = False
    hit_found = False
    # find the bonuses */
    affected = obj.affected
    if not obj.enchanted:
        affected = obj.pIndexData.affected

    for paf in affected:
        if paf.location == merc.APPLY_HITROLL:
            hit_bonus = paf.modifier
            hit_found = True
            fail += 2 * (hit_bonus * hit_bonus)
        elif paf.location == merc.APPLY_DAMROLL:
            dam_bonus = paf.modifier
            dam_found = True
            fail += 2 * (dam_bonus * dam_bonus)
        else:  # things get a little harder */
            fail += 25

    # apply other modifiers */
    fail -= 3 * level // 2

    if obj.flags.bless:
        fail -= 15
    if obj.flags.glow:
        fail -= 5

    fail = max(5, min(fail, 95))

    result = random.randint(1, 99)

    # the moment of truth */
    if result < (fail // 5):  # item destroyed */
        handler_game.act("$p shivers violently and explodes! ", ch, obj, None,
                         merc.TO_CHAR)
        handler_game.act("$p shivers violently and explodeds! ", ch, obj, None,
                         merc.TO_ROOM)
        obj.extract()
        return

    if result < (fail // 2):  # item disenchanted */
        handler_game.act("$p glows brightly, then fades...oops.", ch, obj,
                         None, merc.TO_CHAR)
        handler_game.act("$p glows brightly, then fades.", ch, obj, None,
                         merc.TO_ROOM)
        obj.enchanted = True
        # remove all affects */
        obj.affected[:] = []

        # clear all flags */
        obj.extra_flags = 0
        return

    if result <= fail:  # failed, no bad result */
        ch.send("Nothing seemed to happen.\n")
        return

    # okay, move all the old flags into new vectors if we have to */
    if not obj.enchanted:
        obj.enchanted = True
        for paf in obj.pIndexData.affected:
            af_new = handler_game.AFFECT_DATA()
            af_new.where = paf.where
            af_new.type = max(0, paf.type)
            af_new.level = paf.level
            af_new.duration = paf.duration
            af_new.location = paf.location
            af_new.modifier = paf.modifier
            af_new.bitvector = paf.bitvector
            obj.affected.append(af_new)
    if result <= (100 - level // 5):  # success!  */
        handler_game.act("$p glows blue.", ch, obj, None, merc.TO_CHAR)
        handler_game.act("$p glows blue.", ch, obj, None, merc.TO_ROOM)
        state_checks.SET_BIT(obj.extra_flags, merc.ITEM_MAGIC)
        added = 1
    else:  # exceptional enchant */
        handler_game.act("$p glows a brillant blue! ", ch, obj, None,
                         merc.TO_CHAR)
        handler_game.act("$p glows a brillant blue! ", ch, obj, None,
                         merc.TO_ROOM)
        state_checks.SET_BIT(obj.extra_flags, merc.ITEM_MAGIC)
        state_checks.SET_BIT(obj.extra_flags, merc.ITEM_GLOW)
        added = 2

    # now add the enchantments */
    if obj.level < merc.LEVEL_HERO - 1:
        obj.level = min(merc.LEVEL_HERO - 1, obj.level + 1)

    if dam_found:
        for paf in obj.affected:
            if paf.location == merc.APPLY_DAMROLL:
                paf.type = sn
                paf.modifier += added
                paf.level = max(paf.level, level)
                if paf.modifier > 4:
                    state_checks.SET_BIT(obj.extra_flags, merc.ITEM_HUM)
    else:  # add a new affect */
        paf = handler_game.AFFECT_DATA()

        paf.where = merc.TO_OBJECT
        paf.type = sn
        paf.level = level
        paf.duration = -1
        paf.location = merc.APPLY_DAMROLL
        paf.modifier = added
        paf.bitvector = 0
        obj.affected.append(paf)

    if hit_found:
        for paf in obj.affected:
            if paf.location == merc.APPLY_HITROLL:
                paf.type = sn
                paf.modifier += added
                paf.level = max(paf.level, level)
                if paf.modifier > 4:
                    state_checks.SET_BIT(obj.extra_flags, merc.ITEM_HUM)
    else:  # add a new affect */
        paf = handler_game.AFFECT_DATA()

        paf.type = sn
        paf.level = level
        paf.duration = -1
        paf.location = merc.APPLY_HITROLL
        paf.modifier = added
        paf.bitvector = 0
        obj.affected.append(paf)
示例#14
0
def do_lock(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Lock what?\n")
        return
    obj = ch.get_item_here(arg)
    if obj:
        # portal stuff
        if obj.item_type == merc.ITEM_PORTAL:
            if not state_checks.IS_SET(obj.value[1], merc.EX_ISDOOR) or state_checks.IS_SET(obj.value[1],
                                                                                            merc.EX_NOCLOSE):
                ch.send("You can't do that.\n")
                return
            if not state_checks.IS_SET(obj.value[1], merc.EX_CLOSED):
                ch.send("It's not closed.\n")
                return
            if obj.value[4] < 0 or state_checks.IS_SET(obj.value[1], merc.EX_NOLOCK):
                ch.send("It can't be locked.\n")
                return
            if not ch.has_key(obj.value[4]):
                ch.send("You lack the key.\n")
                return
            if state_checks.IS_SET(obj.value[1], merc.EX_LOCKED):
                ch.send("It's already locked.\n")
                return
            state_checks.SET_BIT(obj.value[1], merc.EX_LOCKED)
            handler_game.act("You lock $p.", ch, obj, None, merc.TO_CHAR)
            handler_game.act("$n locks $p.", ch, obj, None, merc.TO_ROOM)
            return
        # 'lock object'
        if obj.item_type != merc.ITEM_CONTAINER:
            ch.send("That's not a container.\n")
            return
        if not state_checks.IS_SET(obj.value[1], merc.CONT_CLOSED):
            ch.send("It's not closed.\n")
            return
        if obj.value[2] < 0:
            ch.send("It can't be locked.\n")
            return
        if not ch.has_key(obj.value[2]):
            ch.send("You lack the key.\n")
            return
        if state_checks.IS_SET(obj.value[1], merc.CONT_LOCKED):
            ch.send("It's already locked.\n")
            return

        state_checks.SET_BIT(obj.value[1], merc.CONT_LOCKED)
        handler_game.act("You lock $p.", ch, obj, None, merc.TO_CHAR)
        handler_game.act("$n locks $p.", ch, obj, None, merc.TO_ROOM)
        return
    door = handler_room.find_door(ch, arg)
    if door >= 0:
        # 'lock door'
        pexit = ch.in_room.exit[door]
        if not pexit.exit_info.is_set(merc.EX_CLOSED):
            ch.send("It's not closed.\n")
            return
        if pexit.key < 0:
            ch.send("It can't be locked.\n")
            return
        if not ch.has_key(pexit.key):
            ch.send("You lack the key.\n")
            return
        if pexit.exit_info.is_set(merc.EX_LOCKED):
            ch.send("It's already locked.\n")
            return

        pexit.exit_info.set_bit(merc.EX_LOCKED)
        ch.send("*Click*\n")
        handler_game.act("$n locks the $d.", ch, None, pexit.keyword, merc.TO_ROOM)
        # lock the other side
        to_room = pexit.to_room
        if to_room and to_room.exit[merc.rev_dir[door]] != 0 \
                and to_room.exit[merc.rev_dir[door]].to_room == ch.in_room:
            to_room.exit[merc.rev_dir[door]].exit_info.set_bit(merc.EX_LOCKED)
示例#15
0
def spell_enchant_armor(sn, level, ch, victim, target):
    obj = victim
    if obj.item_type != merc.ITEM_ARMOR:
        ch.send("That isn't an armor.\n")
        return

    if not obj.equips_to:
        ch.send("The item must be carried to be enchanted.\n")
        return

    # this means they have no bonus */
    ac_bonus = 0
    ac_found = False
    fail = 25  # base 25% chance of failure */
    affected = obj.affected
    # find the bonuses */
    if not obj.enchanted:
        affected = obj.affected

    for paf in affected:
        if paf.location == merc.APPLY_AC:
            ac_bonus = paf.modifier
            ac_found = True
            fail += 5 * (ac_bonus * ac_bonus)

        else:  # things get a little harder */
            fail += 20

    # apply other modifiers */
    fail -= level

    if obj.flags.bless:
        fail -= 15
    if obj.flags.glow:
        fail -= 5

    fail = max(5, min(fail, 85))

    result = random.randint(1, 99)

    # the moment of truth */
    if result < (fail // 5):  # item destroyed */
        handler_game.act("$p flares blindingly... and evaporates! ", ch, obj,
                         None, merc.TO_CHAR)
        handler_game.act("$p flares blindingly... and evaporates! ", ch, obj,
                         None, merc.TO_ROOM)
        obj.extract()

    if result < (fail // 3):  # item disenchanted */
        handler_game.act("$p glows brightly, then fades...oops.", ch, obj,
                         None, merc.TO_CHAR)
        handler_game.act("$p glows brightly, then fades.", ch, obj, None,
                         merc.TO_ROOM)
        obj.enchanted = True

        # remove all affects */
        obj.affected[:] = []

        # clear all flags */
        obj.extra_flags = 0
        return

    if result <= fail:  # failed, no bad result */
        ch.send("Nothing seemed to happen.\n")
        return

    # okay, move all the old flags into new vectors if we have to */
    if not obj.enchanted:
        obj.enchanted = True
        for paf in obj.pIndexData.affected:
            af_new = handler_game.AFFECT_DATA()
            af_new.where = paf.where
            af_new.type = max(0, paf.type)
            af_new.level = paf.level
            af_new.duration = paf.duration
            af_new.location = paf.location
            af_new.modifier = paf.modifier
            af_new.bitvector = paf.bitvector
            obj.affected.append(af_new)

    if result <= (90 - level // 5):  # success!  */
        handler_game.act("$p shimmers with a gold aura.", ch, obj, None,
                         merc.TO_CHAR)
        handler_game.act("$p shimmers with a gold aura.", ch, obj, None,
                         merc.TO_ROOM)
        state_checks.SET_BIT(obj.extra_flags, merc.ITEM_MAGIC)
        added = -1
    else:  # exceptional enchant */
        handler_game.act("$p glows a brillant gold! ", ch, obj, None,
                         merc.TO_CHAR)
        handler_game.act("$p glows a brillant gold! ", ch, obj, None,
                         merc.TO_ROOM)
        state_checks.SET_BIT(obj.extra_flags, merc.ITEM_MAGIC)
        state_checks.SET_BIT(obj.extra_flags, merc.ITEM_GLOW)
        added = -2

    # now add the enchantments */
    if obj.level < merc.LEVEL_HERO:
        obj.level = min(merc.LEVEL_HERO - 1, obj.level + 1)

    if ac_found:
        for paf in obj.affected:
            if paf.location == merc.APPLY_AC:
                paf.type = sn
                paf.modifier += added
                paf.level = max(paf.level, level)
    else:  # add a new affect */
        paf = handler_game.AFFECT_DATA()

        paf.where = merc.TO_OBJECT
        paf.type = sn
        paf.level = level
        paf.duration = -1
        paf.location = merc.APPLY_AC
        paf.modifier = added
        paf.bitvector = 0
        obj.affected.append(paf)