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)
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)
def cmd_lock(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Lock what?\n") return item = ch.get_item_here(arg) if item: # 'lock 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 locked.\n") return if not ch.valid_key(item.value[2]): ch.send("You lack the key.\n") return if state_checks.is_set(item.value[1], merc.CONT_LOCKED): ch.send("It's already locked.\n") return state_checks.set_bit(item.value[1], merc.CONT_LOCKED) ch.send("*Click*\n") handler_game.act("$n locks $p.", ch, item, 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.valid_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 = 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.set_bit(merc.EX_LOCKED)
def do_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 portal if item.item_type == merc.ITEM_PORTAL: if not state_checks.IS_SET(item.value[1], merc.EX_ISDOOR): ch.send("You can't do that.\n") return if not state_checks.IS_SET(item.value[1], merc.EX_CLOSED): ch.send("It's already open.\n") return if state_checks.IS_SET(item.value[1], merc.EX_LOCKED): ch.send("It's locked.\n") return item.value[1] = state_checks.REMOVE_BIT(item.value[1], merc.EX_CLOSED) handler_game.act("You open $p.", ch, item, None, merc.TO_CHAR) handler_game.act("$n opens $p.", ch, item, None, merc.TO_ROOM) return # 'open 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 already open.\n") return if not state_checks.IS_SET(item.value[1], merc.CONT_CLOSEABLE): 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 item.value[1] = state_checks.REMOVE_BIT(item.value[1], merc.CONT_CLOSED) handler_game.act("You open $p.", ch, item, None, merc.TO_CHAR) 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)
def do_pick(self, argument): ch = self argument, arg = game_utils.read_word(argument) if not arg: ch.send("Pick what?\n") return state_checks.WAIT_STATE(ch, const.skill_table["pick lock"].beats) # look for guards for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if state_checks.IS_NPC(gch) and state_checks.IS_AWAKE(gch) 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 random.randint(1, 99) > ch.get_skill("pick lock"): ch.send("You failed.\n") if ch.is_pc(): ch.check_improve( "pick lock", False, 2) 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): 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: ch.send("It can't be unlocked.\n") return if state_checks.IS_SET(obj.value[1], merc.EX_PICKPROOF): ch.send("You failed.\n") return state_checks.REMOVE_BIT(obj.value[1], merc.EX_LOCKED) handler_game.act("You pick the lock on $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n picks the lock on $p.", ch, obj, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve( "pick lock", True, 2) return # 'pick 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 unlocked.\n") return if not state_checks.IS_SET(obj.value[1], merc.CONT_LOCKED): ch.send("It's already unlocked.\n") return if state_checks.IS_SET(obj.value[1], merc.CONT_PICKPROOF): ch.send("You failed.\n") return state_checks.REMOVE_BIT(obj.value[1], merc.CONT_LOCKED) handler_game.act("You pick the lock on $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n picks the lock on $p.", ch, obj, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve( "pick lock", True, 2) 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) and not ch.is_immortal(): ch.send("It's not closed.\n") return if pexit.key < 0 and not ch.is_immortal(): 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) and not ch.is_immortal(): 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) if ch.is_pc(): ch.check_improve( "pick_lock", True, 2) # unlock 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.rem_bit(merc.EX_LOCKED)
def do_unlock(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Unlock 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): 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: ch.send("It can't be unlocked.\n") return if not ch.has_key(obj.value[4]): ch.send("You lack the key.\n") return if not state_checks.IS_SET(obj.value[1], merc.EX_LOCKED): ch.send("It's already unlocked.\n") return state_checks.REMOVE_BIT(obj.value[1], merc.EX_LOCKED) handler_game.act("You unlock $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n unlocks $p.", ch, obj, None, merc.TO_ROOM) return # 'unlock 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 unlocked.\n") return if not ch.has_key(obj.value[2]): ch.send("You lack the key.\n") return if not state_checks.IS_SET(obj.value[1], merc.CONT_LOCKED): ch.send("It's already unlocked.\n") return state_checks.REMOVE_BIT(obj.value[1], merc.CONT_LOCKED) handler_game.act("You unlock $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n unlocks $p.", ch, obj, 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.has_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 = 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)
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)