Example #1
0
    def enhance_stat(self, level, victim, apply_bit, bonuses, affect_bit):
        if victim.itemaff.is_set(merc.ITEMA_REFLECT):
            # noinspection PyUnresolvedReferences
            self.send("You are unable to focus your spell.\n")
            return

        if state_checks.is_set(affect_bit,
                               merc.AFF_WEBBED) and victim.is_affected(
                                   merc.AFF_WEBBED):
            state_checks.remove_bit(affect_bit, merc.AFF_WEBBED)
        elif state_checks.is_set(
                affect_bit, merc.AFF_WEBBED) and fight.is_safe(self, victim):
            state_checks.remove_bit(affect_bit, merc.AFF_WEBBED)

        if state_checks.is_set(
                affect_bit, merc.AFF_CHARM) and not victim.is_affected.is_set(
                    merc.AFF_CHARM):
            if victim.level <= 50 and (
                    victim.is_npc()
                    or not victim.immune.is_set(merc.IMM_CHARM)):
                if victim.master:
                    victim.stop_follower()
                victim.add_follower(self)
            else:
                # noinspection PyUnresolvedReferences
                self.send("The spell failed.\n")
                return

        aff = handler_game.AffectData(type="reserved",
                                      duration=level,
                                      location=apply_bit,
                                      modifier=bonuses,
                                      bitvector=affect_bit)
        victim.affect_join(aff)
Example #2
0
def cmd_open(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Open what?\n")
        return

    item = ch.get_item_here(arg)
    if item:
        # 'open object'
        if item.item_type not in [merc.ITEM_CONTAINER, merc.ITEM_BOOK]:
            ch.send("That's not a container.\n")
            return

        if not state_checks.is_set(item.value[1], merc.CONT_CLOSED):
            ch.send("It's already open.\n")
            return

        if not state_checks.is_set(
                item.value[1],
                merc.CONT_CLOSEABLE) and item.item_type != merc.ITEM_BOOK:
            ch.send("You can't do that.\n")
            return

        if state_checks.is_set(item.value[1], merc.CONT_LOCKED):
            ch.send("It's locked.\n")
            return

        state_checks.remove_bit(item.value[1], merc.CONT_CLOSED)
        ch.send("Ok.\n")
        handler_game.act("$n opens $p.", ch, item, None, merc.TO_ROOM)
        return

    door = handler_room.find_door(ch, arg)
    if door >= 0:
        # 'open door'
        pexit = ch.in_room.exit[door]
        if not pexit.exit_info.is_set(merc.EX_CLOSED):
            ch.send("It's already open.\n")
            return

        if pexit.exit_info.is_set(merc.EX_LOCKED):
            ch.send("It's locked.\n")
            return

        pexit.exit_info.rem_bit(merc.EX_CLOSED)
        handler_game.act("$n opens the $d.", ch, None, pexit.keyword,
                         merc.TO_ROOM)
        ch.send("Ok.\n")

        # open 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.rem_bit(merc.EX_CLOSED)
            for rch_id in to_room.people[:]:
                rch = instance.characters[rch_id]
                handler_game.act("The $d opens.", rch, None, pexit_rev.keyword,
                                 merc.TO_CHAR)
Example #3
0
def cmd_pick(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Pick what?\n")
        return

    ch.wait_state(const.skill_table["pick lock"].beats)

    # look for guards
    for gch_id in ch.in_room.people:
        gch = instance.characters[gch_id]

        if gch.is_npc() and gch.is_awake() and ch.level + 5 < gch.level:
            handler_game.act("$N is standing too close to the lock.", ch, None,
                             gch, merc.TO_CHAR)
            return

    if not ch.is_npc(
    ) and game_utils.number_percent() > ch.learned["pick lock"]:
        ch.send("You failed.\n")
        return

    item = ch.get_item_here(arg)
    if item:
        # 'pick object'
        if item.item_type != merc.ITEM_CONTAINER:
            ch.send("That's not a container.\n")
            return

        if not state_checks.is_set(item.value[1], merc.CONT_CLOSED):
            ch.send("It's not closed.\n")
            return

        if item.value < 0:
            ch.send("It can't be unlocked.\n")
            return

        if not state_checks.is_set(item.value[1], merc.CONT_LOCKED):
            ch.send("It's already unlocked.\n")
            return

        if state_checks.is_set(item.value[1], merc.CONT_PICKPROOF):
            ch.send("You failed.\n")
            return

        state_checks.remove_bit(item.value[1], merc.CONT_LOCKED)
        ch.send("*Click*\n")
        handler_game.act("$n picks $p.", ch, item, None, merc.TO_ROOM)
        return

    door = handler_room.find_door(ch, arg)
    if door >= 0:
        # 'pick 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 picked.\n")
            return

        if not pexit.exit_info.is_set(merc.EX_LOCKED):
            ch.send("It's already unlocked.\n")
            return

        if pexit.exit_info.is_set(merc.EX_PICKPROOF):
            ch.send("You failed.\n")
            return

        pexit.exit_info.rem_bit(merc.EX_LOCKED)
        ch.send("*Click*\n")
        handler_game.act("$n picks the $d.", ch, None, pexit.keyword,
                         merc.TO_ROOM)

        # pick the other side
        to_room = instance.rooms[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.rem_bit(merc.EX_LOCKED)
Example #4
0
def cmd_unlock(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Unlock what?\n")
        return

    item = ch.get_item_here(arg)
    if item:
        # 'unlock object'
        if item.item_type != merc.ITEM_CONTAINER:
            ch.send("That's not a container.\n")
            return

        if not state_checks.is_set(item.value[1], merc.CONT_CLOSED):
            ch.send("It's not closed.\n")
            return

        if item.value[2] < 0:
            ch.send("It can't be unlocked.\n")
            return

        if not ch.valid_key(item.value[2]):
            ch.send("You lack the key.\n")
            return

        if not state_checks.is_set(item.value[1], merc.CONT_LOCKED):
            ch.send("It's already unlocked.\n")
            return

        state_checks.remove_bit(item.value[1], merc.CONT_LOCKED)
        ch.send("*Click*\n")
        handler_game.act("$n unlocks $p.", ch, item, None, merc.TO_ROOM)
        return

    door = handler_room.find_door(ch, arg)
    if door >= 0:
        # 'unlock 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 unlocked.\n")
            return

        if not ch.valid_key(pexit.key):
            ch.send("You lack the key.\n")
            return

        if not pexit.exit_info.is_set(merc.EX_LOCKED):
            ch.send("It's already unlocked.\n")
            return

        pexit.exit_info.rem_bit(merc.EX_LOCKED)
        ch.send("*Click*\n")
        handler_game.act("$n unlocks the $d.", ch, None, pexit.keyword,
                         merc.TO_ROOM)

        # unlock the other side
        to_room = instance.rooms[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.rem_bit(merc.EX_LOCKED)