def is_note_to(ch, note): if game_utils.str_cmp(ch.name, note.sender): return True if game_utils.is_name("all", note.to_list): return True if ch.is_immortal(): if game_utils.is_name("imm", note.to_list): return True if game_utils.is_name("immortal", note.to_list): return True return game_utils.is_name(ch.name, note.to_list)
def do_owhere(ch, argument): found = False number = 0 max_found = 200 if not argument: ch.send("Find what?\n") return for item in instance.items.values(): if not ch.can_see_item(item) or not game_utils.is_name(argument, item.name) or ch.level < item.level: continue found = True number += 1 content = item.in_item while content.in_item: content = content.in_item if content.in_living and ch.can_see(content.in_living) and content.in_living.in_room: ch.send("%3d) %s is carried by %s [[Room %d]]\n" % ( number, item.short_descr, state_checks.PERS(content.in_living, ch), content.in_living.in_room.vnum )) elif content.in_room and ch.can_see_room(content.in_room): ch.send("%3d) %s is in %s [[Room %d]]\n" % ( number, item.short_descr, content.in_room.name, content.in_room.vnum)) else: ch.send("%3d) %s is somewhere\n" % (number, item.short_descr)) if number >= max_found: break if not found: ch.send("Nothing like that in heaven or earth.\n")
def find_door(ch, arg): arg_list = [(["n", "north"], merc.DIR_NORTH), (["e", "east"], merc.DIR_EAST), (["s", "south"], merc.DIR_SOUTH), (["w", "west"], merc.DIR_WEST), (["u", "up"], merc.DIR_UP), (["d", "down"], merc.DIR_DOWN)] for (aa, bb) in arg_list: if game_utils.str_cmp(arg, aa): door = bb break else: for door in range(merc.MAX_DIR): pexit = ch.in_room.exit[door] if pexit and pexit.exit_info.is_set( merc.EX_ISDOOR) and pexit.keyword and game_utils.is_name( arg, pexit.keyword): return door handler_game.act("I see no $T here.", ch, None, arg, merc.TO_CHAR) return -1 pexit = ch.in_room.exit[door] if not pexit: handler_game.act("I see no door $T here.", ch, None, arg, merc.TO_CHAR) return -1 if not pexit.exit_info.is_set(merc.EX_ISDOOR): ch.send("You can't do that.\n") return -1 return door
def spell_locate_object(sn, level, ch, victim, target): found = False number = 0 max_found = 200 if ch.is_immortal() else 2 * level for item in instance.items.values(): if not ch.can_see_item(item) or not game_utils.is_name(handler_magic.target_name, item.name) \ or item.flags.no_locate or random.randint(1, 99) > 2 * level \ or ch.level < item.level: continue found = True number += 1 in_item = item while in_item.in_item: in_item = in_item.in_item if in_item.in_living and ch.can_see(in_item.in_living): ch.send("one is carried by %s\n" % state_checks.PERS(in_item.in_living, ch)) else: if ch.is_immortal() and in_item.in_room is not None: ch.send("one is in %s [[Room %d]]\n" % (in_item.in_room.name, in_item.in_room.instance_id)) else: ch.send("one is in %s\n" % ("somewhere" if not in_item.in_room else in_item.in_room.name)) if number >= max_found: break if not found: ch.send("Nothing like that in heaven or earth.\n")
def spl_locate_object(sn, level, ch, victim, target): count = 0 found = False for item in list(instance.items.values()): if not ch.can_see_item(item) or not game_utils.is_name( handler_magic.target_name, item.name): continue found = True in_item = item while in_item.in_item: in_item = in_item.in_item if in_item.in_living and ch.can_see(in_item.in_living): buf = "{} is carried by {}.\n".format(item.short_descr, in_item.in_living.pers(ch)) else: buf = "{} is in {}.\n".format( item.short_descr, "somewhere" if not in_item.in_room else in_item.in_room.name) ch.send(buf[0].upper() + buf[1:]) if count > 50: break else: count += 1 if not found: ch.send("Nothing like that in hell, earth, or heaven.\n")
def do_owhere(ch, argument): found = False number = 0 max_found = 200 if not argument: ch.send("Find what?\n") return for item in instance.items.values(): if not ch.can_see_item(item) or not game_utils.is_name( argument, item.name) or ch.level < item.level: continue found = True number += 1 content = item.in_item while content.in_item: content = content.in_item if content.in_living and ch.can_see( content.in_living) and content.in_living.in_room: ch.send("%3d) %s is carried by %s [[Room %d]]\n" % (number, item.short_descr, state_checks.PERS(content.in_living, ch), content.in_living.in_room.vnum)) elif content.in_room and ch.can_see_room(content.in_room): ch.send("%3d) %s is in %s [[Room %d]]\n" % (number, item.short_descr, content.in_room.name, content.in_room.vnum)) else: ch.send("%3d) %s is somewhere\n" % (number, item.short_descr)) if number >= max_found: break if not found: ch.send("Nothing like that in heaven or earth.\n")
def do_ofind(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Find what?\n") return if arg.isdigit(): item_id = instance.instances_by_item[arg][argument] fAll = False # !str_cmp( arg, "all" ) found = False nMatch = 0 # Yeah, so iterating over all vnum's takes 10,000 loops. # Get_obj_index is fast, and I don't feel like threading another link. # Do you? # -- Furey for objTemplate in instance.item_templates.values(): if fAll or game_utils.is_name(arg, objTemplate.name): found = True ch.send( "[[%5d]] %s(%s)\n" % (objTemplate.vnum, objTemplate.short_descr, objTemplate.name)) if not found: ch.send("No objects by that name.\n") return
def spell_locate_object(sn, level, ch, victim, target): found = False number = 0 max_found = 200 if ch.is_immortal() else 2 * level for item in instance.items.values(): if not ch.can_see_item(item) or not game_utils.is_name(handler_magic.target_name, item.name) \ or item.flags.no_locate or random.randint(1, 99) > 2 * level \ or ch.level < item.level: continue found = True number += 1 in_item = item while in_item.in_item: in_item = in_item.in_item if in_item.in_living and ch.can_see(in_item.in_living): ch.send("one is carried by %s\n" % state_checks.PERS(in_item.in_living, ch)) else: if ch.is_immortal() and in_item.in_room is not None: ch.send("one is in %s [[Room %d]]\n" % (in_item.in_room.name, in_item.in_room.instance_id)) else: ch.send("one is in %s\n" % ("somewhere" if not in_item.in_room else in_item.in_room.name)) if number >= max_found: break if not found: ch.send("Nothing like that in heaven or earth.\n")
def cmd_where(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: buf = ["Players near you:\n"] found = False for victim in list(instance.players.values()): if victim.in_room and victim.in_room.area == ch.in_room.area and not victim.chobj and ch.can_see( victim): found = True buf += "{:<28} {}\n".format(victim.name, victim.in_room.name) if not found: buf += "None\n" ch.send("".join(buf)) else: found = False for victim in list(instance.characters.values()): if victim.in_room and victim.in_room.area == ch.in_room.area and not victim.is_affected(merc.AFF_HIDE) and not victim.is_affected(merc.AFF_SNEAK) and \ ch.can_see(victim) and game_utils.is_name(arg, victim.name): found = True ch.send("{:<28} {}\n".format(victim.pers(ch), victim.in_room.area)) break if not found: handler_game.act("You didn't find any $T.", ch, None, arg, merc.TO_CHAR)
def get_item_carry(ch, argument, viewer): number, arg = game_utils.number_argument(argument) count = 0 for item_id in ch.items: item = instance.items.get(item_id, None) if viewer.can_see_item(item) and game_utils.is_name(arg, item.name.lower()): count += 1 if count == number: return item return None
def get_item_list(ch, argument, contents): number, arg = game_utils.number_argument(argument) arg = arg.lower() item_list = [instance.items[item_id] for item_id in contents if game_utils.is_name(arg, instance.items[item_id].name)] if item_list: try: if ch.can_see_item(item_list[number - 1]): return item_list[number - 1] except: return None return None
def spl_ventriloquate(sn, level, ch, victim, target): handler_magic.target_name, speaker = game_utils.read_word( handler_magic.target_name) buf1 = "{} says '{}'.\n".format(speaker, handler_magic.target_name) buf2 = "Someone makes {} say '{}'.\n".format(speaker, handler_magic.target_name) for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if not game_utils.is_name(speaker, vch.name): vch.send(buf2 if handler_magic.saves_spell(level, vch) else buf1)
def get_obj_keeper(ch, keeper, argument): number, arg = game_utils.number_argument(argument) count = 0 for obj_id in keeper.inventory[:]: obj = instance.items[obj_id] if not obj.equipped_to and keeper.can_see_item( obj) and ch.can_see_item(obj) and game_utils.is_name( arg, obj.name): count += 1 if count == number: return obj return None
def get_char_room(ch, argument): number, word = game_utils.number_argument(argument) word = word.lower() if word == "self": return ch number, arg = game_utils.number_argument(argument) ch_list = [instance.characters[rch_id] for rch_id in ch.in_room.people[:] if game_utils.is_name(word, instance.characters[rch_id].name)] if ch_list: try: if ch.can_see(ch_list[number - 1]): return ch_list[number - 1] except: return None return None
def get_char_world(ch, argument): wch = ch.get_char_room(argument) if wch: return wch number, arg = game_utils.number_argument(argument) arg = arg.lower() ch_list = [instance.characters[wch_id] for wch_id in sorted(instance.characters.keys()) if game_utils.is_name(arg, instance.characters[wch_id].name)] if ch_list: try: if ch.can_see(ch_list[number - 1]): return ch_list[number - 1] except: return None return None
def get_item_world(ch, argument): item = ch.get_item_here(argument) if item: return item number, arg = game_utils.number_argument(argument) arg = arg.lower() item_list = [instance.items[item_id] for item_id in sorted(instance.items.keys()) if game_utils.is_name(arg, instance.items[item_id].name)] if item_list: try: if ch.can_see_item(item_list[number - 1]): return item_list[number - 1] except: return None return None
def do_sockets(ch, argument): count = 0 argument, arg = game_utils.read_word(argument) for d in merc.descriptor_list: if d.character and ch.can_see(d.character) \ and (not arg or arg not in d.character.name) \ or (d.original and game_utils.is_name(arg, d.original.name)): count += 1 ch.send("%s@%s\n" % (d.original.name if d.original else d.character.name if d.character else "(none)", d.address)) if count == 0: ch.send("No one by that name is connected.\n") return ch.send("%d user%s\n" % (count, "" if count == 1 else "s")) return
def cmd_help(ch, argument): if not argument: argument = "summary" found = [ h for h in instance.help_list if h.level <= ch.trust and game_utils.is_name(argument, h.keyword) ] for phelp in found: if phelp.level >= 0 and not game_utils.str_cmp(phelp.keyword, "imotd"): ch.send(phelp.keyword + "\n") text = phelp.text[1:] if phelp.text[0] == "." else phelp.text ch.send(text + "\n") return ch.send("No help on that word.\n")
def cmd_mwhere(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Mwhere whom?\n") return buf = [] found = False for victim in list(instance.npcs.values()): if victim.in_room and game_utils.is_name(arg, victim.name): found = True buf += "[{:5}] {:<28} [{:5}] {}\n".format(victim.vnum, victim.short_descr, victim.in_room.vnum, victim.in_room.name) if not found: buf += "You didn't find any {}.".format(arg) ch.send("".join(buf))
def get_item_wear(ch, argument): number, arg = game_utils.number_argument(argument) count = 0 for loc, item_id in ch.equipped.items(): if item_id: item = instance.items[item_id] if ch.can_see_item(item) and game_utils.is_name(arg, item.name.lower()): #print('inside') count += 1 if count == number: #print(item.name, '\n') #print(item.instance_id, '\n') #print(ch.equipped['main_hand']) return item else: continue return None
def do_mfind(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Find whom?\n") return fAll = False # !str_cmp( arg, "all" ) found = False nMatch = 0 # Yeah, so iterating over all vnum's takes 10,000 loops. # Get_mob_index is fast, and I don't feel like threading another link. # Do you? # -- Furey for pMobIndex in instance.npc_templates.values(): if fAll or game_utils.is_name(arg, pMobIndex.name): found = True ch.send("[[%5d]] %s\n" % (pMobIndex.vnum, pMobIndex.short_descr)) if not found: ch.send("No mobiles by that name.\n") return
def do_mfind(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Find whom?\n") return fAll = False # !str_cmp( arg, "all" ) found = False nMatch = 0 # Yeah, so iterating over all vnum's takes 10,000 loops. # Get_mob_index is fast, and I don't feel like threading another link. # Do you? # -- Furey for pMobIndex in instance.npc_templates.values(): if fAll or game_utils.is_name(arg, pMobIndex.name): found = True ch.send("[[%5d]] %s\n" % (pMobIndex.vnum, pMobIndex.short_descr)) if not found: ch.send("No mobiles by that name.\n") return
def spl_create_water(sn, level, ch, victim, target): item = victim if item.item_type != merc.ITEM_DRINK_CON: ch.send("It is unable to hold water.\n") return if item.value[2] != 0 and item.value[1] != 0: ch.send("It contains some other liquid.\n") return water = min(level * (4 if handler_game.weather_info.sky >= merc.SKY_RAINING else 2), item.value[0] - item.value[1]) if water > 0: item.value[2] = 0 item.value[1] += water if not game_utils.is_name("water", item.name): item.name = "{} water".format(item.name) handler_game.act("$p is filled.", ch, item, None, merc.TO_CHAR)
def do_ofind(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Find what?\n") return if arg.isdigit(): item_id = instance.instances_by_item[arg][argument] fAll = False # !str_cmp( arg, "all" ) found = False nMatch = 0 # Yeah, so iterating over all vnum's takes 10,000 loops. # Get_obj_index is fast, and I don't feel like threading another link. # Do you? # -- Furey for objTemplate in instance.item_templates.values(): if fAll or game_utils.is_name(arg, objTemplate.name): found = True ch.send("[[%5d]] %s(%s)\n" % (objTemplate.vnum, objTemplate.short_descr, objTemplate.name)) if not found: ch.send("No objects by that name.\n") return
def cmd_mfind(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Mfind whom?\n") return buf = [] fall = game_utils.str_cmp(arg, "all") nmatch = 0 # Yeah, so iterating over all vnum's takes 10,000 loops. # Get_mob_index is fast, and I don't feel like threading another link. # Do you? # -- Furey for mob in list(instance.npc_templates.values()): if fall or game_utils.is_name(arg, mob.name): nmatch += 1 buf += "[{:5}] {}\n".format(mob.vnum, mob.short_descr) if nmatch == 0: buf += "Nothing like that in hell, earth, or heaven.\n" ch.send("".join(buf))
def get_obj_keeper(ch, keeper, argument): number, arg = game_utils.number_argument(argument) count = 0 for obj_id in keeper.inventory[:]: obj = instance.items[obj_id] if not obj.equipped_to and keeper.can_see_item(obj) and ch.can_see_item(obj) and game_utils.is_name(arg, obj.name): count += 1 if count == number: return obj return None
def cmd_drop(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Drop what?\n") return if arg.isdigit(): # 'drop NNNN coins' amount = int(arg) argument, arg = game_utils.read_word(argument) if amount <= 0 or (not game_utils.str_cmp(arg, ["coins", "coin"])): ch.send("Sorry, you can't do that.\n") return # Otherwise causes complications if there's a pile on each plane if ch.is_affected(merc.AFF_SHADOWPLANE): ch.send("You cannot drop coins in the shadowplane.\n") return if ch.gold < amount: ch.send("You haven't got that many coins.\n") return ch.gold -= amount for item_id in ch.in_room.items: item = instance.items[item_id] if item.vnum == merc.OBJ_VNUM_MONEY_ONE: amount += 1 item.extract() elif item.vnum == merc.OBJ_VNUM_MONEY_SOME: amount += item.value[0] item.extract() object_creator.create_money(amount).to_room(ch.in_room) handler_game.act("$n drops some gold.", ch, None, None, merc.TO_ROOM) ch.send("Ok.\n") ch.save(force=True) return if not game_utils.str_cmp(arg, "all") and not game_utils.str_prefix( "all.", arg): # 'drop obj' item = ch.get_item_carry(arg) if not item: ch.send("You do not have that item.\n") return if not ch.can_drop_item(item): ch.send("You can't let go of it.\n") return ch.get(item) ch.in_room.put(item) # Objects should only have a shadowplane flag when on the floor if ch.is_affected(merc.AFF_SHADOWPLANE) and not item.flags.shadowplane: item.flags.shadowplane = True handler_game.act("$n drops $p.", ch, item, None, merc.TO_ROOM) handler_game.act("You drop $p.", ch, item, None, merc.TO_CHAR) else: # 'drop all' or 'drop all.obj' found = False for item_id in ch.inventory[:]: item = instance.items[item_id] if (len(arg) == 3 or game_utils.is_name(arg[4:], item.name) ) and ch.can_see_item( item) and not item.equipped_to and ch.can_drop_item(item): found = True ch.get(item) ch.in_room.put(item) # Objects should only have a shadowplane flag when on the floor if ch.is_affected( merc.AFF_SHADOWPLANE) and not item.flags.shadowplane: item.flags.shadowplane = True handler_game.act("$n drops $p.", ch, item, None, merc.TO_ROOM) handler_game.act("You drop $p.", ch, item, None, merc.TO_CHAR) if not found: if len(arg) == 3: handler_game.act("You are not carrying anything.", ch, None, arg, merc.TO_CHAR) else: handler_game.act("You are not carrying any $T.", ch, None, arg[4:], merc.TO_CHAR)
def cmd_look(ch, argument): wizard = ch.wizard if not ch.desc and not wizard: return if ch.position < merc.POS_SLEEPING: ch.send("You can't see anything but stars!\n") return if ch.position == merc.POS_SLEEPING: ch.send("You can't see anything, you're sleeping!\n") return if ch.check_blind(): return if not ch.is_npc() and ch.in_room.room_flags.is_set(merc.ROOM_TOTAL_DARKNESS) and not ch.itemaff.is_set(merc.ITEMA_VISION) and \ not ch.is_affected(merc.AFF_SHADOWSIGHT) and not ch.is_immortal(): ch.send("It is pitch black ...\n") return if not ch.is_npc() and not ch.act.is_set(merc.PLR_HOLYLIGHT) and not ch.itemaff.is_set(merc.ITEMA_VISION) and \ not ch.vampaff.is_set(merc.VAM_NIGHTSIGHT) and not ch.is_affected(merc.AFF_SHADOWPLANE) and \ not (ch.in_room and ch.in_room.vnum == merc.ROOM_VNUM_IN_OBJECT and not ch.is_npc() and ch.chobj and ch.chobj.in_obj) and \ ch.in_room.is_dark(): ch.send("It is pitch black ...\n") handler_ch.show_char_to_char(ch.in_room.people, ch) return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or game_utils.str_cmp(arg1, "auto"): # 'look' or 'look auto' if ch.in_room and ch.in_room.vnum == merc.ROOM_VNUM_IN_OBJECT and not ch.is_npc( ) and ch.chobj and ch.chobj.in_obj: handler_game.act("$p", ch, ch.chobj.in_obj, None, merc.TO_CHAR) elif ch.is_affected(merc.AFF_SHADOWPLANE): ch.send("The shadow plane\n") else: ch.send(ch.in_room.name + "\n") if not ch.is_npc() and ch.act.is_set(merc.PLR_AUTOEXIT): ch.cmd_exits("auto") if ch.in_room and ch.in_room.vnum == merc.ROOM_VNUM_IN_OBJECT and not ch.is_npc( ) and ch.chobj and ch.chobj.in_obj: handler_game.act("You are inside $p.", ch, ch.chobj.in_obj, None, merc.TO_CHAR) handler_ch.show_list_to_char(ch.chobj.in_obj.items, ch, False, False) elif (not arg1 or game_utils.str_cmp(arg1, "auto")) and ch.is_affected( merc.AFF_SHADOWPLANE): ch.send("You are standing in complete darkness.\n") elif (not ch.is_npc() and not ch.act.is_set(merc.PLR_BRIEF)) and ( not arg1 or game_utils.str_cmp(arg1, "auto")): ch.send(ch.in_room.description + "\n") if ch.in_room.blood > 0: if ch.in_room.blood == 1000: buf = "#RYou notice that the room is completely drenched in blood.#n\n" elif ch.in_room.blood > 750: buf = "#RYou notice that there is a very large amount of blood around the room.#n\n" elif ch.in_room.blood > 500: buf = "#RYou notice that there is a large quantity of blood around the room.#n\n" elif ch.in_room.blood > 250: buf = "#RYou notice a fair amount of blood on the floor.#n\n" elif ch.in_room.blood > 100: buf = "#RYou notice several blood stains on the floor.#n\n" elif ch.in_room.blood > 50: buf = "#RYou notice a few blood stains on the floor.#n\n" elif ch.in_room.blood > 25: buf = "#RYou notice a couple of blood stains on the floor.#n\n" elif ch.in_room.blood > 0: buf = "#RYou notice a few drops of blood on the floor.#n\n" else: buf = "#RYou notice nothing special in the room.#n\n" ch.send(buf) handler_ch.show_list_to_char(ch.in_room.items, ch, False, False) handler_ch.show_char_to_char(ch.in_room.people, ch) return if game_utils.str_cmp(arg1, ["i", "in"]): # 'look in' if not arg2: ch.send("Look in what?\n") return item = ch.get_item_here(arg2) if not item: ch.send("You do not see that here.\n") return if item.item_type == merc.ITEM_PORTAL: proomindex = instance.rooms[item.value[0]] location = ch.in_room if not proomindex: ch.send("It doesn't seem to lead anywhere.\n") return if item.value[2] == 1 or item.value[2] == 3: ch.send("It seems to be closed.\n") return ch.in_room.get(ch) proomindex.put(ch) for portal_id in ch.in_room.items: portal = instance.items[portal_id] if item.value[0] == portal.value[3] and item.value[ 3] == portal.value[0]: if ch.is_affected(merc.AFF_SHADOWPLANE ) and not portal.flags.shadowplane: ch.affected_by.rem_bit(merc.AFF_SHADOWPLANE) ch.cmd_look("auto") ch.affected_by.set_bit(merc.AFF_SHADOWPLANE) break elif not ch.is_affected( merc.AFF_SHADOWPLANE) and portal.flags.shadowplane: ch.affected_by.set_bit(merc.AFF_SHADOWPLANE) ch.cmd_look("auto") ch.affected_by.rem_bit(merc.AFF_SHADOWPLANE) break else: ch.cmd_look("auto") break ch.in_room.get(ch) location.put(ch) elif item.item_type == merc.ITEM_DRINK_CON: if item.value[1] <= 0: ch.send("It is empty.\n") return if item.value[1] < item.value[0] // 5: ch.send("There is a little {} liquid left in it.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0] // 4: ch.send("It contains a small about of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0] // 3: ch.send("It's about a third full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0] // 2: ch.send("It's about half full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0]: ch.send("It is almost full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] == item.value[0]: ch.send("It's completely full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) else: ch.send("Somehow it is MORE than full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.item_type in [ merc.ITEM_CONTAINER, merc.ITEM_CORPSE_NPC, merc.ITEM_CORPSE_PC ]: if state_checks.is_set(item.value[1], merc.CONT_CLOSED): ch.send("It is closed.\n") return handler_game.act("$p contains:", ch, item, None, merc.TO_CHAR) handler_ch.show_list_to_char(item.inventory, ch, True, True) else: ch.send("That is not a container.\n") return victim = ch.get_char_room(arg1) if victim: handler_ch.show_char_to_char_1(victim, ch) return for vch in list(instance.characters.values()): if not vch.in_room: continue if vch.in_room == ch.in_room: if not vch.is_npc() and game_utils.str_cmp(arg1, vch.morph): handler_ch.show_char_to_char_1(vch, ch) return continue if not ch.is_npc() and ch.chobj and ch.chobj.in_obj: item = ch.get_item_in_item(arg1) if item: ch.send(item.description + "\n") return item_list = list(ch.items) item_list.extend(ch.in_room.items) for item_id in item_list: item = instance.items[item_id] if not ch.is_npc() and ch.chobj and item.chobj and item.chobj == ch: continue if ch.can_see_item(item): pdesc = game_utils.get_extra_descr(arg1, item.extra_descr) if pdesc: ch.send(pdesc) return if game_utils.is_name(arg1, item.name): ch.send(item.description + "\n") return pdesc = game_utils.get_extra_descr(arg1, ch.in_room.extra_descr) if pdesc: ch.send(pdesc) return dir_list = [(["n", "north"], merc.DIR_NORTH), (["e", "east"], merc.DIR_EAST), (["s", "south"], merc.DIR_SOUTH), (["w", "west"], merc.DIR_WEST), (["u", "up"], merc.DIR_UP), (["d", "down"], merc.DIR_DOWN)] for (aa, bb) in dir_list: if game_utils.str_cmp(arg1, aa): door = bb break else: ch.send("You do not see that here.\n") return # 'look direction' pexit = ch.in_room.exit[door] if not pexit: ch.send("Nothing special there.\n") return if pexit.keyword and pexit.keyword[0] != " ": if pexit.exit_info.is_set(merc.EX_CLOSED): handler_game.act("The $d is closed.", ch, None, pexit.keyword, merc.TO_CHAR) elif pexit.exit_info.is_set(merc.EX_ISDOOR): handler_game.act("The $d is open.", ch, None, pexit.keyword, merc.TO_CHAR) pexit = ch.in_room.exit[door] if not pexit: return proomindex = instance.rooms[pexit.to_room] if not proomindex: return location = ch.in_room ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") ch.in_room.get(ch) location.put(ch) else: pexit = ch.in_room.exit[door] if not pexit: return proomindex = instance.rooms[pexit.to_room] if not proomindex: return location = ch.in_room ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") ch.in_room.get(ch) location.put(ch) else: pexit = ch.in_room.exit[door] if not pexit: return proomindex = instance.rooms[pexit.to_room] if not proomindex: return location = ch.in_room ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") ch.in_room.get(ch) location.put(ch)
def do_look(ch, argument): if ch.is_npc() or not ch.desc: return if ch.position < merc.POS_SLEEPING: ch.send("You can't see anything but stars!\n") return if ch.position == merc.POS_SLEEPING: ch.send("You can't see anything, you're sleeping!\n") return if not ch.check_blind(): return room = ch.in_room if not ch.is_npc() and not ch.act.is_set(merc.PLR_HOLYLIGHT) \ and ch.in_room.is_dark(): ch.send("It is pitch black ... \n") handler_ch.show_char_to_char(room.people, ch) return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) number, arg3 = game_utils.number_argument(arg1) count = 0 if not arg1 or arg1 == "auto": # 'look' or 'look auto' ch.send(room.name) if ch.is_immortal() \ and (ch.is_npc() or (ch.act.is_set(merc.PLR_HOLYLIGHT) or ch.act.is_set(merc.PLR_OMNI))): ch.send(" Room[[{room.instance_id}]] Template[[{room.vnum}]]".format(room=room)) ch.send("\n") if not arg1 or (not ch.is_npc() and not ch.comm.is_set(merc.COMM_BRIEF)): ch.send(" %s\n" % room.description) if not ch.is_npc() \ and ch.act.is_set(merc.PLR_AUTOEXIT): ch.send("\n") ch.do_exits("auto") handler_ch.show_list_to_char(room.items, ch, False, False) handler_ch.show_char_to_char(room.people, ch) return if arg1 == "i" or arg1 == "in" or arg1 == "on": # 'look in' if not arg2: ch.send("Look in what?\n") return item = ch.get_item_here(arg2) if not item: ch.send("You do not see that here.\n") return item_type = item.item_type if item_type == merc.ITEM_DRINK_CON: if item.value[1] <= 0: ch.send("It is empty.\n") return if item.value[1] < item.value[0] // 4: amnt = "less than half-" elif item.value[1] < 3 * item.value[0] // 4: amnt = "abount half-" else: amnt = "more than half-" ch.send("It's %sfilled with a %s liquid.\n" % ( amnt, const.liq_table[item.value[2]].color)) elif item_type == merc.ITEM_CONTAINER or item_type == merc.ITEM_CORPSE_NPC \ or item_type == merc.ITEM_CORPSE_PC: if state_checks.IS_SET(item.value[1], merc.CONT_CLOSED): ch.send("It is closed.\n") return handler_game.act("$p holds:", ch, item, None, merc.TO_CHAR) handler_ch.show_list_to_char(item.inventory, ch, True, True) return else: ch.send("That is not a container.\n") return victim = ch.get_char_room(arg1) if victim: handler_ch.show_char_to_char_1(victim, ch) return item_list = ch.items item_list.extend(room.items) for obj_id in item_list: item = instance.items[obj_id] if ch.can_see_item(item): # player can see object pdesc = game_utils.get_extra_descr(arg3, item.extra_descr) if pdesc: count += 1 if count == number: ch.send(pdesc) return else: continue if game_utils.is_name(arg3, item.name.lower()): count += 1 if count == number: ch.send("%s\n" % item.description) return pdesc = game_utils.get_extra_descr(arg3, room.extra_descr) if pdesc: count += 1 if count == number: ch.send(pdesc) return if count > 0 and count != number: if count == 1: ch.send("You only see one %s here.\n" % arg3) else: ch.send("You only see %d of those here.\n" % count) return if "north".startswith(arg1): door = 0 elif "east".startswith(arg1): door = 1 elif "south".startswith(arg1): door = 2 elif "west".startswith(arg1): door = 3 elif "up".startswith(arg1): door = 4 elif "down".startswith(arg1): door = 5 else: ch.send("You do not see that here.\n") return # 'look direction' if door not in room.exit \ or not room.exit[door]: ch.send("Nothing special there.\n") return pexit = room.exit[door] if pexit.description: ch.send(pexit.description) else: ch.send("Nothing special there.\n") if pexit.keyword and pexit.keyword.strip(): if pexit.exit_info.is_set(merc.EX_CLOSED): handler_game.act("The $d is closed.", ch, None, pexit.keyword, merc.TO_CHAR) elif pexit.exit_info.is_set(merc.EX_ISDOOR): handler_game.act("The $d is open.", ch, None, pexit.keyword, merc.TO_CHAR) return
def is_room_owner(self, room): if not room.owner: return False return True if game_utils.is_name(self.name, room.owner) else False
def cmd_put(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Put what in what?\n") return if game_utils.str_cmp(arg2, "all") or game_utils.str_prefix("all.", arg2): ch.send("You can't do that.\n") return container = ch.get_item_here(arg2) if not container: handler_game.act("I see no $T here.", ch, None, arg2, merc.TO_CHAR) return if container.item_type != merc.ITEM_CONTAINER: ch.send("That's not a container.\n") return if state_checks.is_set(container.value[1], merc.CONT_CLOSED): handler_game.act("The $d is closed.", ch, None, container.name, merc.TO_CHAR) return if not game_utils.str_cmp(arg1, "all") and not game_utils.str_prefix( "all.", arg1): # 'put obj container' item = ch.get_item_carry(arg1) if not item: ch.send("You do not have that item.\n") return if item == container: ch.send("You can't fold it into itself.\n") return if item.flags.artifact: ch.send("You cannot put artifacts in a container.\n") return if not ch.can_drop_item(item): ch.send("You can't let go of it.\n") return if item.get_weight() + container.get_weight() > container.value[0]: ch.send("It won't fit.\n") return for item2_id in container.inventory[:]: item2 = instance.items[item2_id] if item2.chobj and item != item2: handler_game.act("A hand reaches inside $P and drops $p.", item2.chobj, item, container, merc.TO_CHAR) ch.get(item) container.put(item) handler_game.act("$n puts $p in $P.", ch, item, container, merc.TO_ROOM) handler_game.act("You put $p in $P.", ch, item, container, merc.TO_CHAR) else: objroom = instance.rooms[merc.ROOM_VNUM_IN_OBJECT] # 'put all container' or 'put all.obj container' for item in ch.inventory[:]: if (len(arg1) == 3 or game_utils.is_name(arg1[4:], item.name)) and ch.can_see_item(item) and not item.equipped_to and \ item != container and not item.flags.artifact and ch.can_drop_item(item) and \ item.get_weight() + container.true_weight() <= container.value[0]: for item2 in container.inventory[:]: if item2.chobj and item2.chobj.in_room: if objroom != instance.rooms[item2.chobj.in_room.vnum]: item2.chobj.in_room.get(item2.chobj) objroom.put(item2.chobj) item2.chobj.cmd_look("auto") if item != item2: handler_game.act( "A hand reaches inside $P and drops $p.", item2.chobj, item, container, merc.TO_CHAR) ch.get(item) container.put(item) handler_game.act("$n puts $p in $P.", ch, item, container, merc.TO_ROOM) handler_game.act("You put $p in $P.", ch, item, container, merc.TO_CHAR) ch.save(force=True)
def is_room_owner(self, room): if not room.owner: return False return True if game_utils.is_name(self.name, room.owner) else False
def do_look(ch, argument): if ch.is_npc() or not ch.desc: return if ch.position < merc.POS_SLEEPING: ch.send("You can't see anything but stars!\n") return if ch.position == merc.POS_SLEEPING: ch.send("You can't see anything, you're sleeping!\n") return if not ch.check_blind(): return room = ch.in_room if not ch.is_npc() and not ch.act.is_set(merc.PLR_HOLYLIGHT) \ and ch.in_room.is_dark(): ch.send("It is pitch black ... \n") handler_ch.show_char_to_char(room.people, ch) return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) number, arg3 = game_utils.number_argument(arg1) count = 0 if not arg1 or arg1 == "auto": # 'look' or 'look auto' ch.send(room.name) if ch.is_immortal() \ and (ch.is_npc() or (ch.act.is_set(merc.PLR_HOLYLIGHT) or ch.act.is_set(merc.PLR_OMNI))): ch.send( " Room[[{room.instance_id}]] Template[[{room.vnum}]]".format( room=room)) ch.send("\n") if not arg1 or (not ch.is_npc() and not ch.comm.is_set(merc.COMM_BRIEF)): ch.send(" %s\n" % room.description) if not ch.is_npc() \ and ch.act.is_set(merc.PLR_AUTOEXIT): ch.send("\n") ch.do_exits("auto") handler_ch.show_list_to_char(room.items, ch, False, False) handler_ch.show_char_to_char(room.people, ch) return if arg1 == "i" or arg1 == "in" or arg1 == "on": # 'look in' if not arg2: ch.send("Look in what?\n") return item = ch.get_item_here(arg2) if not item: ch.send("You do not see that here.\n") return item_type = item.item_type if item_type == merc.ITEM_DRINK_CON: if item.value[1] <= 0: ch.send("It is empty.\n") return if item.value[1] < item.value[0] // 4: amnt = "less than half-" elif item.value[1] < 3 * item.value[0] // 4: amnt = "abount half-" else: amnt = "more than half-" ch.send("It's %sfilled with a %s liquid.\n" % (amnt, const.liq_table[item.value[2]].color)) elif item_type == merc.ITEM_CONTAINER or item_type == merc.ITEM_CORPSE_NPC \ or item_type == merc.ITEM_CORPSE_PC: if state_checks.IS_SET(item.value[1], merc.CONT_CLOSED): ch.send("It is closed.\n") return handler_game.act("$p holds:", ch, item, None, merc.TO_CHAR) handler_ch.show_list_to_char(item.inventory, ch, True, True) return else: ch.send("That is not a container.\n") return victim = ch.get_char_room(arg1) if victim: handler_ch.show_char_to_char_1(victim, ch) return item_list = ch.items item_list.extend(room.items) for obj_id in item_list: item = instance.items[obj_id] if ch.can_see_item(item): # player can see object pdesc = game_utils.get_extra_descr(arg3, item.extra_descr) if pdesc: count += 1 if count == number: ch.send(pdesc) return else: continue if game_utils.is_name(arg3, item.name.lower()): count += 1 if count == number: ch.send("%s\n" % item.description) return pdesc = game_utils.get_extra_descr(arg3, room.extra_descr) if pdesc: count += 1 if count == number: ch.send(pdesc) return if count > 0 and count != number: if count == 1: ch.send("You only see one %s here.\n" % arg3) else: ch.send("You only see %d of those here.\n" % count) return if "north".startswith(arg1): door = 0 elif "east".startswith(arg1): door = 1 elif "south".startswith(arg1): door = 2 elif "west".startswith(arg1): door = 3 elif "up".startswith(arg1): door = 4 elif "down".startswith(arg1): door = 5 else: ch.send("You do not see that here.\n") return # 'look direction' if door not in room.exit \ or not room.exit[door]: ch.send("Nothing special there.\n") return pexit = room.exit[door] if pexit.description: ch.send(pexit.description) else: ch.send("Nothing special there.\n") if pexit.keyword and pexit.keyword.strip(): if pexit.exit_info.is_set(merc.EX_CLOSED): handler_game.act("The $d is closed.", ch, None, pexit.keyword, merc.TO_CHAR) elif pexit.exit_info.is_set(merc.EX_ISDOOR): handler_game.act("The $d is open.", ch, None, pexit.keyword, merc.TO_CHAR) return
def cmd_cast(ch, argument): # Switched NPC's can cast spells, but others can't. if ch.is_npc() and not ch.desc: return # Polymorphed players cannot cast spells if not ch.is_npc() and ch.is_affected( merc.AFF_POLYMORPH) and not ch.vampaff.is_set(merc.VAM_DISGUISED): if not ch.is_obj(): ch.send("You cannot cast spells in this form.\n") return if ch.itemaff.is_set(merc.ITEMA_REFLECT): ch.send("You are unable to focus your spell.\n") return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) handler_magic.target_name = arg2 if not arg1: ch.send("Cast which what where?\n") return sn = handler_magic.find_spell(ch, arg1) if not sn or not sn.spell_fun or (not ch.is_npc() and ch.level < sn.skill_level or ch.learned.get(sn.name, 0) == 0): ch.send("You don't know any spells of that name.\n") return if ch.position < sn.minimum_position: if not ch.is_npc() and not ch.is_vampire() and ch.vampaff.is_set( merc.VAM_CELERITY): if ch.move < 25: ch.send("You can't concentrate enough.\n") return ch.move -= 25 else: if ch.move < 50: ch.send("You can't concentrate enough.\n") return ch.move -= 50 mana = 0 if ch.is_npc() else max( sn.min_mana, 100 // (2 + (ch.level * 12) - sn.skill_level)) if not ch.is_npc() and ch.special.is_set(merc.SPC_WOLFMAN): if ch.powers[merc.WPOWER_OWL] < 4: mana *= 2 # Locate targets. victim = None vo = None target = merc.TARGET_NONE if sn.target == merc.TAR_IGNORE: pass elif sn.target == merc.TAR_CHAR_OFFENSIVE: if not arg2: victim = ch.fighting if not victim: ch.send("Cast the spell on whom?\n") return else: victim = ch.get_char_room(arg2) if not victim: ch.not_here(arg2) return if ch == victim: ch.send("Cast this on yourself? Ok...\n") if victim.itemaff.is_set(merc.ITEMA_REFLECT): ch.send("You are unable to focus your spell upon them.\n") return if not victim.is_npc() and (not ch.can_pk() or not victim.can_pk()) and victim != ch: ch.send("You are unable to affect them.\n") return if not ch.is_npc(): if ch.is_affected(merc.AFF_CHARM) and instance.characters[ ch.master] == victim: ch.send("You can't do that on your own follower.\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_DEFENSIVE: if not arg2: victim = ch else: victim = ch.get_char_room(handler_magic.target_name) if not victim: ch.not_here(handler_magic.target_name) return if victim.itemaff.is_set(merc.ITEMA_REFLECT): ch.send("You are unable to focus your spell upon them.\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_SELF: if arg2 and game_utils.is_name(handler_magic.target_name, ch.name): ch.send("You can't cast this spell on another.\n") return vo = ch target = merc.TARGET_CHAR elif sn.target == merc.TAR_OBJ_INV: if not arg2: ch.send("What should the spell be cast upon?\n") return obj = ch.get_item_carry(handler_magic.target_name) if not obj: ch.send("You are not carrying that.\n") return vo = obj target = merc.TARGET_ITEM else: comm.notify("cmd_cast: bad target for sn {}".format(sn), merc.CONSOLE_ERROR) return if not ch.is_npc() and ch.mana < mana: ch.send("You don't have enough mana.\n") return if not game_utils.str_cmp(sn.name, "ventriloquate"): handler_magic.say_spell(ch, sn) ch.wait_state(sn.beats) if not ch.is_npc() and game_utils.number_percent() > ch.learned[sn.name]: ch.send("You lost your concentration.\n") ch.mana -= mana // 2 ch.improve_spl(sn.target) else: ch.mana -= mana if ch.is_npc(): sn.spell_fun(sn.name, int(ch.level), ch, vo, target) else: sn.spell_fun(sn.name, int(ch.spl[sn.target] * 0.25), ch, vo, target) ch.improve_spl(sn.target) if sn.target == merc.TAR_CHAR_OFFENSIVE and victim != ch and ( victim.master and instance.characters[victim.master] != ch): for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if victim == vch and not victim.fighting: fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) break
def cmd_get(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if ch.is_affected(merc.AFF_ETHEREAL): ch.send("You cannot pick things up while ethereal.\n") return # Get type. if not arg1: ch.send("Get what?\n") return if not arg2: if not game_utils.str_cmp(arg1, "all") and not game_utils.str_prefix( "all.", arg1): # 'get obj' item = ch.get_item_list(arg1, ch.in_room.items) if not item: handler_game.act("I see no $T here.", ch, None, arg1, merc.TO_CHAR) return handler_item.get_item(ch, item, None) else: # 'get all' or 'get all.obj' found = False for item_id in ch.in_room.items: item = instance.items[item_id] if (len(arg1) == 3 or game_utils.is_name( arg1[4:], item.name)) and ch.can_see_item(item): found = True handler_item.get_item(ch, item, None) if not found: if len(arg1) == 3: ch.send("I see nothing here.\n") else: handler_game.act("I see no $T here.", ch, None, arg1[4:], merc.TO_CHAR) else: # 'get ... container' if game_utils.str_cmp(arg2, "all") or game_utils.str_prefix( "all.", arg2): ch.send("You can't do that.\n") return container = ch.get_item_here(arg2) if not container: handler_game.act("I see no $T here.", ch, None, arg2, merc.TO_CHAR) return itype = container.item_type if itype == merc.ITEM_CORPSE_PC: if ch.is_npc(): ch.send("You can't do that.\n") return elif itype not in [merc.ITEM_CONTAINER, merc.ITEM_CORPSE_NPC]: ch.send("That's not a container.\n") return if state_checks.is_set(container.value[1], merc.CONT_CLOSED): handler_game.act("The $d is closed.", ch, None, container.name, merc.TO_CHAR) return if not game_utils.str_cmp(arg1, "all") and not game_utils.str_prefix( "all.", arg1): # 'get obj container' item = ch.get_item_list(arg1, container.inventory) if not item: handler_game.act("I see nothing like that in the $T.", ch, None, arg2, merc.TO_CHAR) return handler_item.get_item(ch, item, container) else: # 'get all container' or 'get all.obj container' found = False for item_id in container.inventory[:]: item = instance.items[item_id] if (len(arg1) == 3 or game_utils.is_name( arg1[4:], item.name)) and ch.can_see_item(item): found = True handler_item.get_item(ch, item, container) if not found: if len(arg1) == 3: handler_game.act("I see nothing in the $T.", ch, None, arg2, merc.TO_CHAR) else: handler_game.act("I see nothing like that in the $T.", ch, None, arg2, merc.TO_CHAR) ch.save(force=True)