def do_authenticator(ch, argument): if ch.is_npc(): return argument, arg1 = game_utils.read_word(argument, False) argument, arg2 = game_utils.read_word(argument, False) if not arg1 or not arg2: ch.send('Authenticator %s.\n' % ('active' if ch.auth else 'disabled')) ch.send('Usage: authenticator <on|off> <password> [token]\n') if ch.auth: import time import sys_utils trials = [ch.auth.time_code(time.time() + offset) for offset in (-30, 0, 30)] ch.send('DEBUG: %s - %s, %r\n' % (sys_utils.sysTimeStamp(time.time()), ch.auth.secret, trials)) return arg1 = arg1.lower() if arg1 == 'on' or arg1 == 'activate' or arg1 == 'enable' or arg1 == 'add': if ch.auth: ch.send('Authentication is already active.\n') return else: pwd = hashlib.sha512(arg2.encode()).hexdigest() if pwd != ch.pwd: ch.send('Wrong password. Operation cancelled.\n') return else: secret = auth.random_base32_token() ch.auth = auth.TwoFactorAuth(secret) ch.save() ch.send('Authentication is now active!\n') ch.send('You must now use Google Authenticator to log in.\n') ch.send('Please add a new time-based account to your authenticator, using %s as the code.\n' % ch.auth.secret) ch.send('If you don\'t have a smartphone app, you can get a Windows version at https://winauth.com/\n') return if arg1 == 'off' or arg1 == 'deactivate' or arg1 == 'disable' or arg1 == 'remove': if not ch.auth: ch.send('Authentication is not active.\n') return else: pwd = hashlib.sha512(arg2.encode()).hexdigest() if pwd != ch.pwd: ch.send('Wrong password. Operation cancelled.\n') return else: argument, arg3 = game_utils.read_word(argument, False) if not arg3: ch.send('You must provide the current auth token to remove your authenticator.\n') return elif not ch.auth.verify(arg3): ch.send('Incorrect token. Operation cancelled.\n') return else: ch.auth = None ch.save() ch.send('Authentication is now disabled.\n') return
def do_guild(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Syntax: guild <char> <cln name>\n") return victim = ch.get_char_world(arg1) if not victim: ch.send("They aren't playing.\n") return if "none".startswith(arg2): ch.send("They are now clanless.\n") victim.send("You are now a member of no clan!\n") victim.clan = 0 return clan = state_checks.prefix_lookup(tables.clan_table, arg2) if not clan: ch.send("No such clan exists.\n") return if clan.independent: ch.send("They are now a %s.\n" % clan.name) victim.send("You are now a %s.\n" % clan.name) else: ch.send("They are now a member of clan %s.\n" % clan.name.capitalize()) victim.send("You are now a member of clan %s.\n" % clan.name.capitalize()) victim.clan = clan.name ch.send("dbeug")
def do_pardon(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Syntax: pardon <character> <killer|thief>.\n") return victim = ch.get_char_world(arg1) if not victim: ch.send("They aren't here.\n") return if victim.is_npc(): ch.send("Not on NPC's.\n") return if arg2 == "killer": if victim.act.is_set(merc.PLR_KILLER): victim.act = victim.act.rem_bit(merc.PLR_KILLER) ch.send("Killer flag removed.\n") victim.send("You are no longer a KILLER.\n") return if arg2 == "thief": if victim.act.is_set(merc.PLR_THIEF): victim.act = victim.act.rem_bit(merc.PLR_THIEF) ch.send("Thief flag removed.\n") victim.send("You are no longer a THIEF.\n") return ch.send("Syntax: pardon <character> <killer|thief>.\n") return
def cmd_rset(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) arg3 = argument if not arg1 or not arg2 or not arg3: ch.send("Syntax: rset <location> <field> value\n\n" "Field being one of:\n" " flags sector\n") return location = game_utils.find_location(ch, arg1) if not location: ch.send("No such location.\n") return # Snarf the value. value = int(arg3) if arg3.isdigit() else -1 # Set something. if game_utils.str_cmp(arg2, "flags"): location.room_flags.bits = value return if game_utils.str_cmp(arg2, "sector"): location.sector_type = value return # Generate usage message. ch.cmd_rset("")
def cmd_trust(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Syntax: trust <char> <trust>\n" "Trust being one of: None, Builder, Questmaker, Enforcer, Judge, or Highjudge.\n") return victim = ch.get_char_room(arg1) if not victim: ch.not_here(arg1) return if victim.is_npc(): ch.not_npc() return arg_list = [("none", 0), ("builder", merc.LEVEL_BUILDER), ("questmaker", merc.LEVEL_QUESTMAKER), ("enforcer", merc.LEVEL_ENFORCER), ("judge", merc.LEVEL_JUDGE), ("highjudge", merc.LEVEL_HIGHJUDGE)] for (aa, bb) in arg_list: if game_utils.str_cmp(arg2, aa): level = bb break else: ch.cmd_trust("") return if level >= ch.trust: ch.send("Limited to below your trust.\n") return ch.send("Ok.\n") victim.trust = level
def do_password(ch, argument): if ch.is_npc(): return # Can't use read_word here because it smashes case. # So we just steal all its code. Bleagh. # -- It actually doesn't now because it loads areas too. Davion. argument, arg1 = game_utils.read_word(argument, False) argument, arg2 = game_utils.read_word(argument, False) if not arg1 or not arg2: ch.send("Syntax: password <old> <new>.\n") return if settings.ENCRYPT_PASSWORD: # Had to add .encode() for unicode text input. arg1 = hashlib.sha512(arg1.encode()).hexdigest() arg2 = hashlib.sha512(arg2.encode()).hexdigest() if arg1 != ch.pwd: state_checks.WAIT_STATE(ch, 40) ch.send("Wrong password. Wait 10 seconds.\n") return if len(arg2) < 5: ch.send("New password must be at least five characters long.\n") return # No tilde allowed because of player file format. # Also now not true. Davion ch.pwd = arg2 ch.save() ch.send("Ok.\n") return
def crack_head(ch, item, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not game_utils.str_cmp(arg2, "mob") and item.chobj and not item.chobj.is_npc() and item.chobj.is_affected(merc.AFF_POLYMORPH): victim = item.chobj object_creator.make_part(victim, "cracked_head") object_creator.make_part(victim, "brain") victim.morph = "the quivering brain of {}".format(victim.name) elif game_utils.str_cmp(arg2, "mob"): mob_index = instance.npc_templates[item.value[1]] if not mob_index: return victim = object_creator.create_mobile(mob_index) ch.in_room.put(victim) object_creator.make_part(victim, "cracked_head") object_creator.make_part(victim, "brain") victim.extract(True) else: mob_index = instance.npc_templates[30002] if not mob_index: return victim = object_creator.create_mobile(mob_index) victim.short_descr = arg2[0].upper() + arg2[1:] ch.in_room.put(victim) object_creator.make_part(victim, "cracked_head") object_creator.make_part(victim, "brain") victim.extract(True)
def do_force(ch, argument): argument, arg = game_utils.read_word(argument) if not arg or not argument: ch.send("Force whom to do what?\n") return temp, arg2 = game_utils.read_word(argument) if arg2 == "delete": ch.send("That will NOT be done.\n") return buf = "$n forces you to '%s'." % argument if arg == "all": if ch.trust < merc.MAX_LEVEL - 3: ch.send("Not at your level!\n") return for vch in instance.characters.values(): if not vch.is_npc() and vch.trust < ch.trust: handler_game.act(buf, ch, None, vch, merc.TO_VICT) vch.interpret(argument) elif arg == "players": if ch.trust < merc.MAX_LEVEL - 2: ch.send("Not at your level!\n") return for vch in instance.characters.values(): if not vch.is_npc( ) and vch.trust < ch.trust and vch.level < merc.LEVEL_HERO: handler_game.act(buf, ch, None, vch, merc.TO_VICT) vch.interpret(argument) elif arg == "gods": if ch.trust < merc.MAX_LEVEL - 2: ch.send("Not at your level!\n") return for vch in instance.characters.values(): if not vch.is_npc( ) and vch.trust < ch.trust and vch.level >= merc.LEVEL_HERO: handler_game.act(buf, ch, None, vch, merc.TO_VICT) vch.interpret(argument) else: victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("Aye aye, right away!\n") return if not ch.is_room_owner(victim.in_room) and ch.in_room != victim.in_room \ and victim.in_room.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL): ch.send("That character is in a private room.\n") return if victim.is_pc() and victim.trust >= ch.trust: ch.send("Do it yourself!\n") return if not victim.is_npc() and ch.trust < merc.MAX_LEVEL - 3: ch.send("Not at your level!\n") return handler_game.act(buf, ch, None, victim, merc.TO_VICT) #TODO: Known broken. NPCs don't have interpret, so we'll have to figure this out. victim.interpret(argument) ch.send("Ok.\n") return
def do_split(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Split how much?\n") return amount_gold = 0 amount_silver = 0 if arg1.isdigit(): amount_silver = int(arg1) if arg2.isdigit(): amount_gold = int(arg2) if amount_gold < 0 or amount_silver < 0: ch.send("Your group wouldn't like that.\n") return if amount_gold == 0 and amount_silver == 0: ch.send("You hand out zero coins, but no one notices.\n") return if ch.gold < amount_gold or ch.silver < amount_silver: ch.send("You don't have that much to split.\n") return members = 0 for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if gch.is_same_group(ch) and not state_checks.IS_AFFECTED(gch, merc.AFF_CHARM): members += 1 if members < 2: ch.send("Just keep it all.\n") return share_silver = amount_silver // members extra_silver = amount_silver % members share_gold = amount_gold // members extra_gold = amount_gold % members if share_gold == 0 and share_silver == 0: ch.send("Don't even bother, cheapskate.\n") return ch.silver -= amount_silver ch.silver += share_silver + extra_silver ch.gold -= amount_gold ch.gold += share_gold + extra_gold if share_silver > 0: ch.send("You split %d silver coins. Your share is %d silver.\n" % (amount_silver, share_silver + extra_silver)) if share_gold > 0: ch.send("You split %d gold coins. Your share is %d gold.\n" % (amount_gold, share_gold + extra_gold)) if share_gold == 0: buf = "$n splits %d silver coins. Your share is %d silver." % (amount_silver, share_silver) elif share_silver == 0: buf = "$n splits %d gold coins. Your share is %d gold." % (amount_gold, share_gold) else: buf = '$n splits %d silver and %d gold coins, giving you %d silver and %d gold.\n' % ( amount_silver, amount_gold, share_silver, share_gold) for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if gch != ch and gch.is_same_group(ch) and not state_checks.IS_AFFECTED(gch, merc.AFF_CHARM): handler_game.act(buf, ch, None, gch, merc.TO_VICT) gch.gold += share_gold gch.silver += share_silver return
def cmd_password(ch, argument): if ch.is_npc(): return # Can't use read_word here because it smashes case. # So we just steal all its code. Bleagh. # -- It actually doesn't now because it loads areas too. Davion. argument, arg1 = game_utils.read_word(argument, to_lower=False) argument, arg2 = game_utils.read_word(argument, to_lower=False) if not arg1 or not arg2: ch.send("Syntax: password <old> <new>\n") return if arg1 != ch.pwd: ch.wait_state(40) ch.send("Wrong password. Wait 10 seconds.\n") return if len(arg2) < 5: ch.send("New password must be at least five characters long.\n") return ch.pwd = arg2 ch.save(force=True) ch.send("Ok.\n")
def spl_engrave(sn, level, ch, victim, target): handler_magic.target_name, arg1 = game_utils.read_word( handler_magic.target_name) handler_magic.target_name, arg2 = game_utils.read_word( handler_magic.target_name) if ch.is_npc(): return if not arg1 or not arg2: ch.send("What spell do you wish to engrave, and on what?\n") return sn = handler_magic.find_spell(ch, arg2) if not sn or not sn.spell_fun or (not ch.is_npc() and ch.level < sn.skill_level): ch.send("You can't do that.\n") return if ch.learned[sn] < 100: ch.send("You are not adept at that spell.\n") return item = ch.get_item_carry(arg1) if not item: ch.send("You are not carrying that.\n") return if item.item_type != merc.ITEM_STAFF: ch.send("That is not a staff.\n") return if item.value[0] != 0 or item.value[1] != 0 or item.value[ 2] != 0 or item.value[3] != 0: ch.send("You need an unenchanted staff.\n") return item_list = [(merc.PURPLE_MAGIC, "purple"), (merc.RED_MAGIC, "red"), (merc.BLUE_MAGIC, "blue"), (merc.GREEN_MAGIC, "green"), (merc.YELLOW_MAGIC, "yellow")] for (aa, bb) in item_list: if sn.target == aa: item.value[0] = ch.spl[aa] // 4 col = bb break else: ch.send("Oh dear...big bug...please inform an Immortal.\n") return item.value[1] = (item.value[0] // 10) + 1 item.value[2] = (item.value[0] // 10) + 1 item.value[3] = sn item.name = "{} staff {} {}".format(ch.name, col, sn.name) item.short_descr = "{}'s {} staff of {}".format(ch.name, col, sn.name) item.description = "A {} staff is lying here.".format(col) item.flags.take = True item.hold = True handler_game.act("You engrave $p.", ch, item, None, merc.TO_CHAR) handler_game.act("$n engraves $p.", ch, item, None, merc.TO_ROOM)
def do_oset(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) arg3 = argument if not arg1 or not arg2 or not arg3: ch.send("Syntax:\n") ch.send(" set obj <object> <field> <value>\n") ch.send(" Field being one of:\n") ch.send(" value0 value1 value2 value3 value4 (v1-v4)\n") ch.send(" extra wear level weight cost timer\n") return obj = ch.get_item_world(arg1) if not obj: ch.send("Nothing like that in heaven or earth.\n") return # Snarf the value (which need not be numeric). value = int(arg3) if arg3.isdigit else -1 if value == -1: ch.do_oset("") # Set something. if arg2 == "value0" or arg2 == "v0": obj.value[0] = min(50, value) return if arg2 == "value1" or arg2 == "v1": obj.value[1] = value return if arg2 == "value2" or arg2 == "v2": obj.value[2] = value return if arg2 == "value3" or arg2 == "v3": obj.value[3] = value return if arg2 == "value4" or arg2 == "v4": obj.value[4] = value return if "extra".startswith(arg2): obj.extra_flags = value return if "wear".startswith(arg2): obj.wear_flags = value return if "level".startswith(arg2): obj.level = value return if "weight".startswith(arg2): obj.weight = value return if "cost".startswith(arg2): obj.cost = value return if "timer".startswith(arg2): obj.timer = value return # Generate usage message. ch.do_oset("") return
def do_force(ch, argument): argument, arg = game_utils.read_word(argument) if not arg or not argument: ch.send("Force whom to do what?\n") return temp, arg2 = game_utils.read_word(argument) if arg2 == "delete": ch.send("That will NOT be done.\n") return buf = "$n forces you to '%s'." % argument if arg == "all": if ch.trust < merc.MAX_LEVEL - 3: ch.send("Not at your level!\n") return for vch in instance.characters.values(): if not vch.is_npc() and vch.trust < ch.trust: handler_game.act(buf, ch, None, vch, merc.TO_VICT) vch.interpret( argument) elif arg == "players": if ch.trust < merc.MAX_LEVEL - 2: ch.send("Not at your level!\n") return for vch in instance.characters.values(): if not vch.is_npc() and vch.trust < ch.trust and vch.level < merc.LEVEL_HERO: handler_game.act(buf, ch, None, vch, merc.TO_VICT) vch.interpret(argument) elif arg == "gods": if ch.trust < merc.MAX_LEVEL - 2: ch.send("Not at your level!\n") return for vch in instance.characters.values(): if not vch.is_npc() and vch.trust < ch.trust and vch.level >= merc.LEVEL_HERO: handler_game.act(buf, ch, None, vch, merc.TO_VICT) vch.interpret(argument) else: victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("Aye aye, right away!\n") return if not ch.is_room_owner(victim.in_room) and ch.in_room != victim.in_room \ and victim.in_room.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL): ch.send("That character is in a private room.\n") return if victim.is_pc() and victim.trust >= ch.trust: ch.send("Do it yourself!\n") return if not victim.is_npc() and ch.trust < merc.MAX_LEVEL - 3: ch.send("Not at your level!\n") return handler_game.act(buf, ch, None, victim, merc.TO_VICT) #TODO: Known broken. NPCs don't have interpret, so we'll have to figure this out. victim.interpret(argument) ch.send("Ok.\n") return
def cmd_compare(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Compare what to what?\n") return item1 = ch.get_item_carry(arg1) if not item1: ch.send("You do not have that item.\n") return if not arg2: item2 = None for obj in ch.inventory[:]: if obj.equipped_to and ch.can_see_item(obj) and item1.item_type == obj.item_type and \ (item1.equips_to & obj.equips_to & ~merc.ITEM_TAKE) != 0: item2 = obj break if not item2: ch.send("You aren't wearing anything comparable.\n") return else: item2 = ch.get_item_carry(arg2) if not item2: ch.send("You do not have that item.\n") return msg = None value1 = 0 value2 = 0 if item1 == item2: msg = "You compare $p to itself. It looks about the same." elif item1.item_type != item2.item_type: msg = "You can't compare $p and $P." else: if item1.item_type == merc.ITEM_ARMOR: value1 = item1.value[0] value2 = item2.value[0] elif item1.item_type == merc.ITEM_WEAPON: value1 = item1.value[1] + item1.value[2] value2 = item2.value[1] + item2.value[2] else: msg = "You can't compare $p and $P." if not msg: if value1 == value2: msg = "$p and $P look about the same." elif value1 > value2: msg = "$p looks better than $P." else: msg = "$p looks worse than $P." handler_game.act(msg, ch, item1, item2, merc.TO_CHAR)
def do_advance(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2 or not arg2.isdigit(): ch.send("Syntax: advance <char> <level>.\n") return victim = ch.get_char_world(arg1) if not victim: ch.send("That player is not here.\n") return if victim.is_npc(): ch.send("Not on NPC's.\n") return level = int(arg2) if level < 1 or level > merc.MAX_LEVEL: ch.send("Level must be 1 to %d.\n" % merc.MAX_LEVEL) return if level > ch.trust: ch.send("Limited to your trust level.\n") return # Lower level: # Reset to level 1. # Then raise again. # Currently, an imp can lower another imp. # -- Swiftest if level <= victim.level: ch.send("Lowering a player's level!\n") victim.send("**** OOOOHHHHHHHHHH NNNNOOOO ****\n") temp_prac = victim.practice victim.level = 1 victim.exp = victim.exp_per_level(victim.points) victim.max_hit = 10 victim.max_mana = 100 victim.max_move = 100 victim.practice = 0 victim.hit = victim.max_hit victim.mana = victim.max_mana victim.move = victim.max_move update.advance_level(victim, True) victim.practice = temp_prac else: ch.send("Raising a player's level!\n") victim.send("**** OOOOHHHHHHHHHH YYYYEEEESSS ****\n") for iLevel in range(victim.level, level): victim.level += 1 update.advance_level(victim, True) victim.send("You are now level %d.\n" % victim.level) victim.exp = victim.exp_per_level(victim.points) * max(1, victim.level) victim.trust = 0 victim.save() return
def cmd_create(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: itemtype = merc.ITEM_TRASH else: type_list = [("light", merc.ITEM_LIGHT), ("scroll", merc.ITEM_SCROLL), ("wand", merc.ITEM_WAND), ("staff", merc.ITEM_STAFF), ("weapon", merc.ITEM_WEAPON), ("treasure", merc.ITEM_TREASURE), (["armor", "armour"], merc.ITEM_ARMOR), ("potion", merc.ITEM_POTION), ("furniture", merc.ITEM_FURNITURE), ("trash", merc.ITEM_TRASH), ("container", merc.ITEM_CONTAINER), ("drink", merc.ITEM_DRINK_CON), ("key", merc.ITEM_KEY), ("food", merc.ITEM_FOOD), ("money", merc.ITEM_MONEY), ("boat", merc.ITEM_BOAT), ("corpse", merc.ITEM_CORPSE_NPC), ("fountain", merc.ITEM_FOUNTAIN), ("pill", merc.ITEM_PILL), ("portal", merc.ITEM_PORTAL), ("egg", merc.ITEM_EGG), ("stake", merc.ITEM_STAKE), ("missile", merc.ITEM_MISSILE)] for (aa, bb) in type_list: if game_utils.str_cmp(arg1, aa): itemtype = bb break else: itemtype = merc.ITEM_TRASH if not arg2 or not arg2.isdigit(): level = 0 else: level = int(arg2) if level not in merc.irange(1, 50): ch.send("Level should be within range 1 to 50.\n") return obj_index = instance.item_templates[merc.OBJ_VNUM_PROTOPLASM] if not obj_index: ch.send("Error...missing object, please inform an Immortal.\n") return item = object_creator.create_item(obj_index, level) item.item_type = itemtype ch.put(item) item.questmaker = ch.name handler_game.act( "You reach up into the air and draw out a ball of protoplasm.", ch, item, None, merc.TO_CHAR) handler_game.act( "$n reaches up into the air and draws out a ball of protoplasm.", ch, item, None, merc.TO_ROOM)
def load_npcs(area, parea): area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound while w != "0": vnum = int(w) if vnum in instance.npc_templates: comm.notify("load_npcs: vnum {} duplicated.".format(vnum), merc.CONSOLE_CRITICAL) sys.exit(1) npc = handler_npc.Npc() npc.vnum = vnum instance.npc_templates[npc.vnum] = npc npc.area = parea.name area, npc.name = game_utils.read_string(area) npc.name = npc.name.lower() area, npc.short_descr = game_utils.read_string(area) area, npc.long_descr = game_utils.read_string(area) npc.long_descr = miniboa.terminal.escape(npc.long_descr, "ANSI") area, npc.description = game_utils.read_string(area) npc.description = miniboa.terminal.escape(npc.description, "ANSI") area, act = game_utils.read_int(area) npc.act.bits = act | merc.ACT_IS_NPC area, affected_by = game_utils.read_int(area) npc.affected_by.bits = affected_by area, npc.alignment = game_utils.read_int(area) area, letter = game_utils.read_letter(area) area, level = game_utils.read_int(area) npc.level = game_utils.number_fuzzy(level) area, npc.hitroll = game_utils.read_int(area) area, npc.armor = game_utils.read_word(area) area, dummy = game_utils.read_int(area) area = game_utils.read_forward(area) area, dummy = game_utils.read_int(area) area = game_utils.read_forward(area) area, dummy = game_utils.read_int(area) area, dummy = game_utils.read_int(area) area = game_utils.read_forward(area) area, dummy = game_utils.read_int(area) area = game_utils.read_forward(area) area, dummy = game_utils.read_int(area) area, npc.gold = game_utils.read_int(area) area, dummy = game_utils.read_int(area) area, dummy = game_utils.read_int(area) area, dummy = game_utils.read_int(area) area, npc.sex = game_utils.read_int(area) area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound return area
def do_compare(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Compare what to what?\n") return obj1 = ch.get_item_carry(arg1, ch) if not obj1: ch.send("You do not have that item.\n") return obj2 = None if not arg2: for obj2 in ch.inventory[:]: if obj2.equipped_to and ch.can_see_item(obj2) and obj1.item_type == obj2.item_type \ and (obj1.equips_to & obj2.equips_to & ~merc.ITEM_TAKE) != 0: break if not obj2: ch.send("You aren't wearing anything comparable.\n") return else: obj2 = ch.get_item_carry(arg2, ch) if not obj2: ch.send("You do not have that item.\n") return msg = None value1 = 0 value2 = 0 if obj1 is obj2: msg = "You compare $p to itself. It looks about the same." elif obj1.item_type != obj2.item_type: msg = "You can't compare $p and $P." else: if obj1.item_type == merc.ITEM_ARMOR: value1 = obj1.value[0] + obj1.value[1] + obj1.value[2] value2 = obj2.value[0] + obj2.value[1] + obj2.value[2] elif obj1.item_type == merc.ITEM_WEAPON: value1 = (1 + obj1.value[2]) * obj1.value[1] value2 = (1 + obj2.value[2]) * obj2.value[1] else: msg = "You can't compare $p and $P." if msg is None: if value1 == value2: msg = "$p and $P look about the same." elif value1 > value2: msg = "$p looks better than $P." else: msg = "$p looks worse than $P." handler_game.act(msg, ch, obj1, obj2, merc.TO_CHAR) return
def load_rooms(area, pArea): area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound while w != '0': room = handler_room.Room() room.vnum = int(w) if room.vnum in instance.room_templates: logger.critical('Dupicate room Vnum: %d', room.vnum) sys.exit(1) instance.room_templates[room.vnum] = room room.area = pArea area, room.name = game_utils.read_string(area) area, room.description = game_utils.read_string(area) area, number = game_utils.read_int(area) # area number area, room.room_flags = game_utils.read_flags(area) area, room.sector_type = game_utils.read_int(area) while True: area, letter = game_utils.read_letter(area) if letter == 'S': break elif letter == 'H': # Healing Room area, room.heal_rate = game_utils.read_int(area) elif letter == 'M': # Mana Room area, room.mana_rate = game_utils.read_int(area) elif letter == 'C': # Clan area, room.clan = game_utils.read_string(area) elif letter == 'D': # exit nexit = world_classes.Exit() area, door = game_utils.read_int(area) area, nexit.description = game_utils.read_string(area) area, nexit.keyword = game_utils.read_string(area) area, locks = game_utils.read_int(area) area, nexit.key = game_utils.read_int(area) area, nexit.to_room = game_utils.read_int(area) room.exit[door] = nexit elif letter == 'E': ed = world_classes.ExtraDescrData() area, ed.keyword = game_utils.read_string(area) area, ed.description = game_utils.read_string(area) room.extra_descr.append(ed) elif letter == 'O': area, room.owner = game_utils.read_string(area) else: logger.critical("RoomIndexData(%d) has flag other than SHMCDEO: %s", (room.vnum, letter)) sys.exit(1) area, w = game_utils.read_word(area, False) w = w[1:] # strip the pound pArea.room_dict[room.vnum] = room return area
def cmd_divorce(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Syntax: divorse <person> <person>\n") return victim1 = ch.get_char_room(arg1) if not victim1: ch.not_here(arg1) return victim2 = ch.get_char_room(arg2) if not victim2: ch.not_here(arg2) return if victim1.is_npc() or victim2.is_npc(): ch.not_npc() return if victim1.act.is_set(merc.PLR_GODLESS) and ch.level < merc.NO_GODLESS: ch.send("You failed.\n") return if victim2.act.is_set(merc.PLR_GODLESS) and ch.level < merc.NO_GODLESS: ch.send("You failed.\n") return if game_utils.str_cmp(victim1.name, victim2.marriage) and game_utils.str_cmp( victim2.name, victim1.marriage): if not victim1.extra.is_set( merc.EXTRA_MARRIED) or not victim2.extra.is_set( merc.EXTRA_MARRIED): ch.send("But they are not married!\n") return victim1.extra.rem_bit(merc.EXTRA_MARRIED) victim2.extra.rem_bit(merc.EXTRA_MARRIED) victim1.marriage = "" victim2.marriage = "" victim1.save(force=True) victim2.save(force=True) comm.info("{} and {} are now divorced!".format(victim1.name, victim2.name)) return ch.send("But they are not married!\n")
def cmd_sset(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) argument, arg3 = game_utils.read_word(argument) if not arg1 or not arg2 or not arg3: ch.send("Syntax: sset <victim> <skill> <value>\n" "or: sset <victim> all <value>\n" "Skill being any skill or spell.\n") return victim = ch.get_char_world(arg1) if not victim: ch.not_here(arg1) return if victim.is_npc(): ch.not_npc() return if victim.act.is_set( merc.PLR_GODLESS ) and ch.trust < merc.NO_GODLESS and not ch.extra.is_set( merc.EXTRA_ANTI_GODLESS): ch.send("You failed.\n") return fall = game_utils.str_cmp(arg2, "all") sn = state_checks.prefix_lookup(const.skill_table, arg2) if not fall and not sn: ch.send("No such skill or spell.\n") return # Snarf the value. if not arg3.isdigit(): ch.send("Value must be numeric.\n") return value = int(arg3) if value not in merc.irange(0, 100): ch.send("Value range is 0 to 100.\n") return if fall: for sn in const.skill_table.keys(): victim.learned[sn] = value else: victim.learned[sn.name] = value ch.send("Ok.\n")
def do_invis(ch, argument): # RT code for taking a level argument argument, arg = game_utils.read_word(argument) if not arg: # take the default path if ch.invis_level: ch.invis_level = 0 handler_game.act("$n slowly fades into existence.", ch, None, None, merc.TO_ROOM) ch.send("You slowly fade back into existence.\n") else: ch.invis_level = ch.trust handler_game.act("$n slowly fades into thin air.", ch, None, None, merc.TO_ROOM) ch.send("You slowly vanish into thin air.\n") else: # do the level thing level = int(arg) if arg.isdigit() else -1 if level < 2 or level > ch.trust: ch.send("Invis level must be between 2 and your level.\n") return else: ch.reply = None ch.invis_level = level handler_game.act("$n slowly fades into thin air.", ch, None, None, merc.TO_ROOM) ch.send("You slowly vanish into thin air.\n") return
def do_kill(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Kill whom?\n") return victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return # Allow player killing # if not IS_NPC(victim) and not IS_SET(victim.act, PLR_KILLER) and not IS_SET(victim.act, PLR_THIEF): # ch.send("You must MURDER a player.\n") # return if victim == ch: ch.send("You hit yourself. Ouch!\n") fight.multi_hit(ch, ch, merc.TYPE_UNDEFINED) return if fight.is_safe(ch, victim): return if victim.fighting and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: handler_game.act("$N is your beloved master.", ch, None, victim, merc.TO_CHAR) return if ch.position == merc.POS_FIGHTING: ch.send("You do the best you can!\n") return state_checks.WAIT_STATE(ch, 1 * merc.PULSE_VIOLENCE) fight.check_killer(ch, victim) fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) return
def do_fill(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Fill what?\n") return obj = ch.get_item_carry(arg, ch) if not obj: ch.send("You do not have that item.\n") return for f_id in ch.in_room.items: f = instance.items[f_id] if f.item_type == merc.ITEM_FOUNTAIN: fountain = f break if not fountain: ch.send("There is no fountain here!\n") return if obj.item_type != merc.ITEM_DRINK_CON: ch.send("You can't fill that.\n") return if obj.value[1] != 0 and obj.value[2] != fountain.value[2]: ch.send("There is already another liquid in it.\n") return if obj.value[1] >= obj.value[0]: ch.send("Your container is full.\n") return handler_game.act("You fill $p with %s from $P." % const.liq_table[fountain.value[2]].name, ch, obj, fountain, merc.TO_CHAR) handler_game.act("$n fills $p with %s from $P." % const.liq_table[fountain.value[2]].name, ch, obj, fountain, merc.TO_ROOM) obj.value[2] = fountain.value[2] obj.value[1] = obj.value[0] return
def do_disconnect(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Disconnect whom?\n") return if arg.isdigit(): desc = int(arg) for d in merc.descriptor_list: if d.descriptor == desc: comm.close_socket(d) ch.send("Ok.\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim.desc is None: handler_game.act("$N doesn't have a descriptor.", ch, None, victim, merc.TO_CHAR) return for d in merc.descriptor_list: if d == victim.desc: comm.close_socket(d) ch.send("Ok.\n") return logger.warn("BUG: Do_disconnect: desc not found.") ch.send("Descriptor not found!\n") return
def do_incognito(ch, argument): # RT code for taking a level argument argument, arg = game_utils.read_word(argument) if not arg: # take the default path if ch.incog_level: ch.incog_level = 0 handler_game.act("$n is no longer cloaked.", ch, None, None, merc.TO_ROOM) ch.send("You are no longer cloaked.\n") else: ch.incog_level = ch.trust handler_game.act("$n cloaks $s presence.", ch, None, None, merc.TO_ROOM) ch.send("You cloak your presence.\n") else: # do the level thing level = int(arg) if arg.isdigit() else -1 if level < 2 or level > ch.trust: ch.send("Incog level must be between 2 and your level.\n") return else: ch.reply = None ch.incog_level = level handler_game.act("$n cloaks $s presence.", ch, None, None, merc.TO_ROOM) ch.send("You cloak your presence.\n") return
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
def do_follow(ch, argument): # RT changed to allow unlimited following and follow the NOFOLLOW rules argument, arg = game_utils.read_word(argument) if not arg: ch.send("Follow whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.send("They aren't here.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master: handler_game.act("But you'd rather follow $N!", ch, None, ch.master, merc.TO_CHAR) return if victim == ch: if ch.master is None: ch.send("You already follow yourself.\n") return handler_ch.stop_follower(ch) return if not victim.is_npc() \ and victim.act.is_set(merc.PLR_NOFOLLOW) \ and not ch.is_immortal(): handler_game.act("$N doesn't seem to want any followers.\n", ch, None, victim, merc.TO_CHAR) return ch.act.rem_bit(merc.PLR_NOFOLLOW) if ch.master: handler_ch.stop_follower(ch) handler_ch.add_follower(ch, victim) return
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
def do_where(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Players near you:\n") found = False for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) \ and victim \ and not victim.is_npc() \ and victim.in_room \ and not state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NOWHERE) \ and (ch.is_room_owner(victim.in_room) or not victim.in_room.is_private()) \ and victim.in_room.area == ch.in_room.area \ and ch.can_see(victim): found = True ch.send("%-28s %s\n" % (victim.name, victim.in_room.name)) if not found: ch.send("None\n") else: found = False for victim in 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 arg in victim.name.lower(): found = True ch.send("%-28s %s\n" % (state_checks.PERS(victim, ch), victim.in_room.name)) break if not found: handler_game.act("You didn't find any $T.", ch, None, arg, merc.TO_CHAR) return
def do_practice(ch, argument): temp, argument = game_utils.read_word(argument) if ch.is_npc(): return if not argument: col = 0 for sn, skill in const.skill_table.items(): if ch.level < skill.skill_level[ch.guild.name] \ or sn not in ch.learned or ch.learned[sn] < 1: # skill is not known continue ch.send("%-18s %3d%% " % (skill.name, ch.learned[sn])) col += 1 if col % 3 == 0: ch.send("\n") if col % 3 != 0: ch.send("\n") ch.send("You have %d practice sessions left.\n" % ch.practice) else: if not ch.is_awake(): ch.send("In your dreams, or what?\n") return practitioner = None for mob_id in ch.in_room.people: mob = instance.characters[mob_id] if mob.is_npc() and mob.act.is_set(merc.ACT_PRACTICE): practitioner = mob if not practitioner: ch.send("You can't do that here.\n") return else: mob = practitioner if ch.practice <= 0: ch.send("You have no practice sessions left.\n") return skill = state_checks.prefix_lookup(const.skill_table, argument) if not skill or not ch.is_npc() \ and (ch.level < skill.skill_level[ch.guild.name] or ch.learned[skill.name] < 1 \ or skill.rating[ch.guild.name] == 0): ch.send("You can't practice that.\n") return adept = 100 if ch.is_npc() else ch.guild.skill_adept if ch.learned[skill.name] >= adept: ch.send("You are already learned at %s.\n" % skill.name) else: ch.practice -= 1 ch.learned[skill.name] += const.int_app[ch.stat(merc.STAT_INT)].learn // skill.rating[ ch.guild.name] if ch.learned[skill.name] < adept: handler_game.act("You practice $T.", ch, None, skill.name, merc.TO_CHAR) handler_game.act("$n practices $T.", ch, None, skill.name, merc.TO_ROOM) else: ch.learned[skill.name] = adept handler_game.act("You are now learned at $T.", ch, None, skill.name, merc.TO_CHAR) handler_game.act("$n is now learned at $T.", ch, None, skill.name, merc.TO_ROOM) return
def do_at(ch, argument): argument, arg = game_utils.read_word(argument) if not arg or not argument: ch.send("At where what?\n") return location = game_utils.find_location(ch, arg) if not location: ch.send("No such location.\n") return if not ch.is_room_owner(location) and location.is_private() \ and ch.trust < merc.MAX_LEVEL: ch.send("That room is private right now.\n") return original = ch.in_room on = ch.on original.get(ch) location.put(ch) ch.interpret(argument) # See if 'ch' still exists before continuing! # Handles 'at XXXX quit' case. for wch in instance.characters.values(): if wch == ch: location.get(ch) original.put(ch) ch.on = on break
def do_value(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Value what?\n") return keeper = shop_utils.find_keeper(ch) if not keeper: return obj = ch.get_item_carry(arg, ch) if not obj: handler_game.act("$n tells you 'You don't have that item'.", keeper, None, ch, merc.TO_VICT) ch.reply = keeper return if not keeper.can_see_item(obj): handler_game.act("$n doesn't see what you are offering.",keeper,None,ch, merc.TO_VICT) return if not ch.can_drop_item(obj): ch.send("You can't let go of it.\n") return cost = shop_utils.get_cost(keeper, obj, False) if cost <= 0: handler_game.act( "$n looks uninterested in $p.", keeper, obj, ch, merc.TO_VICT) return handler_game.act("$n tells you 'I'll give you %d silver and %d gold coins for $p'." % (cost - (cost//100) * 100, cost//100), keeper, obj, ch, merc.TO_VICT) ch.reply = keeper return
def do_stat(ch, argument): string, arg = game_utils.read_word(argument) if not arg: ch.send("Syntax:\n") ch.send(" stat <name>\n") ch.send(" stat obj <name>\n") ch.send(" stat mob <name>\n") ch.send(" stat room <number>\n") return if arg == "room": ch.do_rstat(string) return if arg == "obj": ch.do_ostat(string) return if arg == "char" or arg == "mob": ch.do_mstat(string) return # do it the old way obj = ch.get_item_world(argument) if obj: ch.do_ostat(argument) return victim = ch.get_char_world(argument) if victim: ch.do_mstat(argument) return location = game_utils.find_location(ch, argument) if location: ch.do_rstat(argument) return ch.send("Nothing by that name found anywhere.\n")
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
def do_order(ch, argument): argument, arg = game_utils.read_word(argument) remainder, arg2 = game_utils.read_word(argument) if arg2 == "delete": ch.send("That will NOT be done.\n") return if not arg or not argument: ch.send("Order whom to do what?\n") return if ch.is_affected(merc.AFF_CHARM): ch.send("You feel like taking, not giving, orders.\n") return victim = None if arg == "all": fAll = True victim = None else: fAll = False victim = ch.get_char_room(arg) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("Aye aye, right away!\n") return if not victim.is_affected( merc.AFF_CHARM) or victim.master != ch \ or (state_checks.IS_IMMORTAL(victim) and victim.trust >= ch.trust): ch.send("Do it yourself!\n") return found = False for och_id in ch.in_room.people[:]: och = instance.characters[och_id] if state_checks.IS_AFFECTED(och, merc.AFF_CHARM) \ and och.master == ch \ and (fAll or och == victim): found = True handler_game.act("$n orders you to '%s'." % argument, ch, None, och, merc.TO_VICT) och.interpret(argument) if found: state_checks.WAIT_STATE(ch, merc.PULSE_VIOLENCE) ch.send("Ok.\n") else: ch.send("You have no followers here.\n") return
def spell_ventriloquate(sn, level, ch, victim, target): target_name, speaker = game_utils.read_word(target_name) buf1 = "%s says '%s'.\n" % (speaker.capitalize(), target_name) buf2 = "Someone makes %s say '%s'.\n" % (speaker, target_name) for vch_id in ch.in_room.people: vch = instance.characters[vch_id] if not is_exact_name(speaker, vch.name) and state_checks.IS_AWAKE(vch): vch.send(buf2 if handler_magic.saves_spell(level, vch, merc.DAM_OTHER) else buf1)
def do_transfer(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Transfer whom (and where)?\n") return if arg1 == "all": for d in merc.descriptor_list: if d.is_connected(nanny.con_playing) \ and d.character != ch \ and d.character.in_room \ and ch.can_see(d.character): ch.do_transfer("%s %s" % d.character.name, arg2) return # Thanks to Grodyn for the optional location parameter. if not arg2: location = ch.in_room else: location = game_utils.find_location(ch, arg2) if not location: ch.send("No such location.\n") return if not ch.is_room_owner(location) and location.is_private() \ and ch.trust < merc.MAX_LEVEL: ch.send("That room is private right now.\n") return victim = ch.get_char_world(arg1) if not victim: ch.send("They aren't here.\n") return if victim.in_room is None: ch.send("They are in limbo.\n") return if victim.fighting: fight.stop_fighting(victim, True) handler_game.act("$n disappears in a mushroom cloud.", victim, None, None, merc.TO_ROOM) victim.in_room.get(victim) location.put(victim) handler_game.act("$n arrives from a puff of smoke.", victim, None, None, merc.TO_ROOM) if ch != victim: handler_game.act("$n has transferred you.", ch, None, victim, merc.TO_VICT) victim.do_look("auto") ch.send("Ok.\n")
def do_restore(ch, argument): junky, arg = game_utils.read_word(argument) if not arg or arg == "room": # cure room for vch_id in ch.in_room.people: vch = instance.characters[vch_id] vch.affect_strip("plague") vch.affect_strip("poison") vch.affect_strip("blindness") vch.affect_strip("sleep") vch.affect_strip("curse") vch.hit = vch.max_hit vch.mana = vch.max_mana vch.move = vch.max_move fight.update_pos(vch) handler_game.act("$n has restored you.", ch, None, vch, merc.TO_VICT) handler_game.wiznet("$N restored room %d." % ch.in_room.vnum, ch, None, merc.WIZ_RESTORE, merc.WIZ_SECURE, ch.trust) ch.send("Room restored.\n") return if ch.trust >= merc.MAX_LEVEL - 1 and arg == "all": # cure all for d in merc.descriptor_list: victim = d.character if victim is None or victim.is_npc(): continue victim.affect_strip("plague") victim.affect_strip("poison") victim.affect_strip("blindness") victim.affect_strip("sleep") victim.affect_strip("curse") victim.hit = victim.max_hit victim.mana = victim.max_mana victim.move = victim.max_move fight.update_pos(victim) if victim.in_room: handler_game.act("$n has restored you.", ch, None, victim, merc.TO_VICT) ch.send("All active players restored.\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return victim.affect_strip("plague") victim.affect_strip("poison") victim.affect_strip("blindness") victim.affect_strip("sleep") victim.affect_strip("curse") victim.hit = victim.max_hit victim.mana = victim.max_mana victim.move = victim.max_move fight.update_pos(victim) handler_game.act("$n has restored you.", ch, None, victim, merc.TO_VICT) buf = "$N restored %s", (victim.short_descr if victim.is_npc() else victim.name) handler_game.wiznet(buf, ch, None, merc.WIZ_RESTORE, merc.WIZ_SECURE, ch.trust) ch.send("Ok.\n") return
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 check_social(ch, command, argument): cmd = None for social in merc.social_list: if social.name.lower().startswith(command): cmd = social if not cmd: return False if not ch.is_npc() and ch.comm.is_set(merc.COMM_NOEMOTE): ch.send("You are anti-social!\n") return True if ch.position == merc.POS_DEAD: ch.send("Lie still; you are DEAD.\n") return True if ch.position == merc.POS_INCAP or ch.position == merc.POS_MORTAL: ch.send("You are hurt far too bad for that.\n") return True if ch.position == merc.POS_STUNNED: ch.send("You are too stunned to do that.\n") return True if ch.position == merc.POS_SLEEPING: # I just know this is the path to a 12" 'if' statement. :( # But two players asked for it already! -- Furey if cmd.name != "snore": ch.send("In your dreams, or what?\n") return True holder, arg = game_utils.read_word(argument) victim = ch.get_char_room(arg) if not arg: handler_game.act(cmd.others_no_arg, ch, None, victim, merc.TO_ROOM) handler_game.act(cmd.char_no_arg, ch, None, victim, merc.TO_CHAR) elif not victim: ch.send("They aren't here.\n") elif victim == ch: handler_game.act(cmd.others_auto, ch, None, victim, merc.TO_ROOM) handler_game.act(cmd.char_auto, ch, None, victim, merc.TO_CHAR) else: handler_game.act(cmd.others_found, ch, None, victim, merc.TO_NOTVICT) handler_game.act(cmd.char_found, ch, None, victim, merc.TO_CHAR) handler_game.act(cmd.vict_found, ch, None, victim, merc.TO_VICT) if not ch.is_npc() and victim.is_npc() \ and not victim.is_affected(merc.AFF_CHARM) \ and state_checks.IS_AWAKE(victim) and victim.desc is None: num = random.randint(0, 12) if num in [0, 1, 2, 3, 4, 5, 6, 7, 8]: handler_game.act(cmd.others_found, victim, None, ch, merc.TO_NOTVICT) handler_game.act(cmd.char_found, victim, None, ch, merc.TO_CHAR) handler_game.act(cmd.vict_found, victim, None, ch, merc.TO_VICT) elif num in [9, 10, 11, 12]: handler_game.act("$n slaps $N.", victim, None, ch, merc.TO_NOTVICT) handler_game.act("You slap $N.", victim, None, ch, merc.TO_CHAR) handler_game.act("$n slaps you.", victim, None, ch, merc.TO_VICT) return True
def do_alias(ch, argument): if ch.is_npc(): return argument, arg = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg: if not ch.alias: ch.send("You have no aliases defined.\n") return ch.send("Your current aliases are:\n") for alias, sub in ch.alias.iteritems(): ch.send(" %s: %s\n" % (alias, sub)) return if "unalias" == arg or "alias" == arg: ch.send("Sorry, that word is reserved.\n") return if not arg2: if arg not in ch.alias: ch.send("That alias is not defined.\n") return ch.send("%s aliases to '%s'.\n" % (arg, ch.alias[arg])) return if arg2.startswith("delete") or arg2.startswith("prefix"): ch.send("That shall not be done!\n") return if arg2 in ch.alias: ch.alias[arg] = arg2 ch.send("%s is now realiased to '%s'.\n" % (arg, arg2)) return elif len(ch.alias) > merc.MAX_ALIAS: ch.send("Sorry, you have reached the alias limit.\n") return ch.alias[arg] = arg2 ch.send("%s is now aliased to '%s'.\n" % (arg, arg2)) return