def do_notell(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Notell whom?") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim.trust >= ch.trust: ch.send("You failed.\n") return if victim.comm.is_set(merc.COMM_NOTELL): victim.comm = state_checks.REMOVE_BIT(victim.comm, merc.COMM_NOTELL) victim.send("You can tell again.\n") ch.send("NOTELL removed.\n") handler_game.wiznet("$N restores tells to %s." % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) else: victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_NOTELL) victim.send("You can't tell!\n") ch.send("NOTELL set.\n") handler_game.wiznet("$N revokes %s's tells." % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) return
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_nochannels(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Nochannel whom?") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim.trust >= ch.trust: ch.send("You failed.\n") return if victim.comm.is_set(merc.COMM_NOCHANNELS): victim.comm = state_checks.REMOVE_BIT(victim.comm, merc.COMM_NOCHANNELS) victim.send("The gods have restored your channel priviliges.\n") ch.send("NOCHANNELS removed.\n") handler_game.wiznet("$N restores channels to %s" % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) else: victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_NOCHANNELS) victim.send("The gods have revoked your channel priviliges.\n") ch.send("NOCHANNELS set.\n") handler_game.wiznet("$N revokes %s's channels." % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) return
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_delete(ch, argument): if ch.is_npc(): return if ch.confirm_delete: if argument: ch.send("Delete status removed.\n") ch.confirm_delete = False return else: pfile = os.path.join(settings.PLAYER_DIR, ch.name + '.json') handler_game.wiznet("$N turns $Mself into line noise.", ch, None, 0, 0, 0) fight.stop_fighting(ch, True) ch.do_quit("") os.remove(pfile) return if argument: ch.send("Just type delete. No argument.\n") return ch.send("Type delete again to confirm this command.\n") ch.send("WARNING: this command is irreversible.\n") ch.send("Typing delete with an argument will undo delete status.\n") ch.confirm_delete = True handler_game.wiznet("$N is contemplating deletion.", ch, None, 0, 0, ch.trust)
def do_quit(ch, argument): if ch.is_npc(): return if ch.position == merc.POS_FIGHTING: ch.send("No way! You are fighting.\n") return if ch.position < merc.POS_STUNNED: ch.send("You're not DEAD yet.\n") return ch.send("Alas, all good things must come to an end.\n") handler_game.act("$n has left the game.", ch, None, None, merc.TO_ROOM) logger.info("%s has quit.", ch.name) handler_game.wiznet("$N rejoins the real world.", ch, None, merc.WIZ_LOGINS, 0, ch.trust) # After extract_char the ch is no longer valid! ch.save(logout=True, force=True) #save.legacy_save_char_obj(ch) id = ch.id d = ch.desc ch.extract(True) if d is not None: comm.close_socket(d) # toast evil cheating bastards for d in merc.descriptor_list[:]: tch = handler_ch.CH(d) if tch and tch.id == id: tch.extract(True) comm.close_socket(d) return
def do_oload(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg1.isdigit(): ch.send("Syntax: load obj <vnum> <level>.\n") return level = ch.trust # default if arg2: # load with a level if not arg2.isdigit(): ch.send("Syntax: oload <vnum> <level>.\n") return level = int(arg2) if level < 0 or level > ch.trust: ch.send("Level must be be between 0 and your level.\n") return vnum = int(arg1) if vnum not in instance.item_templates: ch.send("No object has that vnum.\n") return item = object_creator.create_item(instance.item_templates[vnum], level) if item.flags.take: ch.put(item) else: ch.in_room.put(item) handler_game.act("$n has created $p!", ch, item, None, merc.TO_ROOM) handler_game.wiznet("$N loads $p.", ch, item, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust) ch.send("Ok.\n") return
def con_get_timecode(self): argument = self.get_command() ch_dummy = self.character if not ch_dummy.stub['auth'].verify(argument): ch_dummy.send('\nWrong timecode.\n') ch_dummy.failed_attempts += 1 if ch_dummy.failed_attempts > 3: comm.close_socket(self) else: ch_dummy.send('Authenticator code: ') self.set_connected(con_get_timecode) return ch_dummy.send("\n") if comm.check_playing(self, ch_dummy.name): return if comm.check_reconnect(self, ch_dummy.name, True): return ch = handler_pc.Pc.load(ch_dummy.name) del ch_dummy ch.send = self.send ch.desc = self self.character = ch log_buf = "%s@%s has connected." % (ch.name, self.addrport()) logger.info(log_buf) handler_game.wiznet(log_buf, None, None, merc.WIZ_SITES, 0, ch_dummy.trust) if ch.is_immortal(): ch.do_help("imotd") self.set_connected(con_read_imotd) else: ch.do_help("motd") self.set_connected(con_read_motd) return
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_newlock(ch, argument): if not settings.NEWLOCK: handler_game.wiznet("$N locks out new characters.", ch, None, 0, 0, 0) ch.send("New characters have been locked out.\n") settings.NEWLOCK = True else: handler_game.wiznet("$N allows new characters back in.", ch, None, 0, 0, 0) ch.send("Newlock removed.\n") settings.NEWLOCK = False return
def do_wizlock(ch, argument): if not settings.WIZLOCK: handler_game.wiznet("$N has wizlocked the game.", ch, None, 0, 0, 0) ch.send("Game wizlocked.\n") settings.WIZLOCK = True else: handler_game.wiznet("$N removes wizlock.", ch, None, 0, 0, 0) ch.send("Game un-wizlocked.\n") settings.WIZLOCK = False return
def gain_exp(ch, gain): if ch.is_npc() or ch.level >= merc.LEVEL_HERO: return ch.exp = max(ch.exp_per_level(ch.points), ch.exp + gain) while ch.level < merc.LEVEL_HERO and ch.exp >= ch.exp_per_level(ch.points) * (ch.level + 1): ch.send("You raise a level!! ") ch.level += 1 print("%s gained level %d\r\n" % (ch.name, ch.level)) handler_game.wiznet("$N has attained level %d!" % ch.level, ch, None, merc.WIZ_LEVELS, 0, 0) advance_level(ch, False) ch.save()
def gain_exp(ch, gain): if ch.is_npc() or ch.level >= merc.LEVEL_HERO: return ch.exp = max(ch.exp_per_level(ch.points), ch.exp + gain) while ch.level < merc.LEVEL_HERO and ch.exp >= ch.exp_per_level( ch.points) * (ch.level + 1): ch.send("You raise a level!! ") ch.level += 1 print("%s gained level %d\r\n" % (ch.name, ch.level)) handler_game.wiznet("$N has attained level %d!" % ch.level, ch, None, merc.WIZ_LEVELS, 0, 0) advance_level(ch, False) ch.save()
def con_get_old_password(self): argument = self.get_command() ch_dummy = self.character ch_dummy.desc.password_mode_off() if settings.ENCRYPT_PASSWORD: argument = argument.encode('utf8') pwdcmp = hashlib.sha512(argument).hexdigest() else: pwdcmp = argument if pwdcmp != ch_dummy.stub['pwd']: ch_dummy.send("\nWrong password.\n") ch_dummy.failed_attempts += 1 if ch_dummy.failed_attempts > 3: comm.close_socket(self) else: ch_dummy.send("Password: "******"\n") if comm.check_playing(self, ch_dummy.name): return if comm.check_reconnect(self, ch_dummy.name, True): return ch = handler_pc.Pc.load(ch_dummy.name) del ch_dummy ch.send = self.send ch.desc = self self.character = ch log_buf = "%s@%s has connected." % (ch.name, self.addrport()) logger.info(log_buf) handler_game.wiznet(log_buf, None, None, merc.WIZ_SITES, 0, ch.trust) if ch.is_immortal(): ch.do_help("imotd") self.set_connected(con_read_imotd) else: ch.do_help("motd") self.set_connected(con_read_motd) return
def do_mload(ch, argument): argument, arg = game_utils.read_word(argument) if not arg or not arg.isdigit(): ch.send("Syntax: load mob <vnum>.\n") return vnum = int(arg) if vnum not in instance.npc_templates: ch.send("No mob has that vnum.\n") return template = instance.npc_templates[vnum] victim = object_creator.create_mobile(template) ch.in_room.put(victim) handler_game.act("$n has created $N!", ch, None, victim, merc.TO_ROOM) handler_game.wiznet("$N loads %s." % victim.short_descr, ch, None, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust) ch.send("Ok.\n") return
def update_handler(): global previous_pulse global pulse_area global pulse_npc global pulse_violence global pulse_point current_time = get_precise_time() if previous_pulse == -1: previous_pulse = current_time - 1 while current_time >= previous_pulse + merc.MILLISECONDS_PER_PULSE: previous_pulse += merc.MILLISECONDS_PER_PULSE pulse_area -= 1 pulse_npc -= 1 pulse_violence -= 1 pulse_point -= 1 for ch in instance.characters.values(): if ch.daze > 0: ch.daze -= 1 if ch.wait > 0: ch.wait -= 1 if pulse_area <= 0: pulse_area = merc.PULSE_AREA db.area_update() instance_number_save( ) # Piggyback on area updates to save the instance number. if pulse_npc <= 0: pulse_npc = merc.PULSE_MOBILE npc_update() if pulse_violence <= 0: hotfix.poll_files() pulse_violence = merc.PULSE_VIOLENCE fight.violence_update() if pulse_point <= 0: handler_game.wiznet("TICK!", None, None, merc.WIZ_TICKS, 0, 0) pulse_point = merc.PULSE_TICK # weather_update ( ) char_update() item_update() aggr_update()
def update_handler(): global previous_pulse global pulse_area global pulse_npc global pulse_violence global pulse_point current_time = get_precise_time() if previous_pulse == -1: previous_pulse = current_time-1 while current_time >= previous_pulse + merc.MILLISECONDS_PER_PULSE: previous_pulse += merc.MILLISECONDS_PER_PULSE pulse_area -= 1 pulse_npc -= 1 pulse_violence -= 1 pulse_point -= 1 for ch in instance.characters.values(): if ch.daze > 0: ch.daze -= 1 if ch.wait > 0: ch.wait -= 1 if pulse_area <= 0: pulse_area = merc.PULSE_AREA db.area_update() instance_number_save() # Piggyback on area updates to save the instance number. if pulse_npc <= 0: pulse_npc = merc.PULSE_MOBILE npc_update() if pulse_violence <= 0: hotfix.poll_files() pulse_violence = merc.PULSE_VIOLENCE fight.violence_update() if pulse_point <= 0: handler_game.wiznet("TICK!", None, None, merc.WIZ_TICKS, 0, 0) pulse_point = merc.PULSE_TICK # weather_update ( ) char_update() item_update() aggr_update()
def do_snoop(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Snoop whom?\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if not victim.desc: ch.send("No descriptor to snoop.\n") return if victim == ch: ch.send("Cancelling all snoops.\n") handler_game.wiznet("$N stops being such a snoop.", ch, None, merc.WIZ_SNOOPS, merc.WIZ_SECURE, ch.trust) for d in merc.descriptor_list: if d.snoop_by == ch.desc: d.snoop_by = None return if victim.desc.snoop_by: ch.send("Busy already.\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.trust >= ch.trust or victim.comm.is_set(merc.COMM_SNOOP_PROOF): ch.send("You failed.\n") return if ch.desc: d = ch.desc.snoop_by while d: if d.character == victim or d.original == victim: ch.send("No snoop loops.\n") return d = d.snoop_by victim.desc.snoop_by = ch.desc buf = "$N starts snooping on %s" % (victim.short_descr if ch.is_npc() else victim.name) handler_game.wiznet(buf, ch, None, merc.WIZ_SNOOPS, merc.WIZ_SECURE, ch.trust) ch.send("Ok.\n") return
def do_sacrifice(ch, argument): argument, arg = game_utils.read_word(argument) if not arg or arg == ch.name.lower(): handler_game.act("$n offers $mself to Mota, who graciously declines.", ch, None, None, merc.TO_ROOM) ch.send("Mota appreciates your offer and may accept it later.\n") return item = ch.get_item_list(arg, ch.in_room.items) if item is None: ch.send("You can't find it.\n") return if item.item_type == merc.ITEM_CORPSE_PC: if item.inventory: ch.send("Mota wouldn't like that.\n") return if not item.flags.take or item.flags.no_sac: handler_game.act("$p is not an acceptable sacrifice.", ch, item, 0, merc.TO_CHAR) return if item.in_room: for gch_id in item.in_room.people: gch = instance.characters[gch_id] if gch.on == item.instance_id: handler_game.act("$N appears to be using $p.", ch, item, gch, merc.TO_CHAR) return silver = max(1, item.level * 3) if item.item_type != merc.ITEM_CORPSE_NPC and item.item_type != merc.ITEM_CORPSE_PC: silver = min(silver, item.cost) if silver == 1: ch.send("Mota gives you one silver coin for your sacrifice.\n") else: ch.send("Mota gives you %d silver coins for your sacrifice.\n" % silver) ch.silver += silver if ch.act.is_set(merc.PLR_AUTOSPLIT): # AUTOSPLIT code members = len([gch for gch in ch.in_room.people if gch.is_same_group(ch)]) if members > 1 and silver > 1: ch.do_split("%d" % silver) handler_game.act("$n sacrifices $p to Mota.", ch, item, None, merc.TO_ROOM) handler_game.wiznet("$N sends up $p as a burnt offering.", ch, item, merc.WIZ_SACCING, 0, 0) ch.in_room.get(item) item.extract() return
def do_switch(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Switch into whom?\n") return if not ch.desc is None: return if ch.desc.original: ch.send("You are already switched.\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("Ok.\n") return if not victim.is_npc(): ch.send("You can only switch into mobiles.\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.desc: ch.send("Character in use.\n") return handler_game.wiznet("$N switches into %s" % victim.short_descr, ch, None, merc.WIZ_SWITCHES, merc.WIZ_SECURE, ch.trust) ch.desc.character = victim ch.desc.original = ch victim.desc = ch.desc ch.desc = None # change communications to match if ch.prompt: victim.prompt = ch.prompt victim.comm = ch.comm victim.lines = ch.lines victim.send("Ok.\n") return
def do_return(ch, argument): if not ch.desc: return if not ch.desc.original: ch.send("You aren't switched.\n") return ch.send( "You return to your original body. Type replay to see any missed tells.\n" ) if ch.prompt: ch.prompt = '' handler_game.wiznet("$N returns from %s." % ch.short_descr, ch.desc.original, 0, merc.WIZ_SWITCHES, merc.WIZ_SECURE, ch.trust) ch.desc.character = ch.desc.original ch.desc.original = None ch.desc.character.desc = ch.desc ch.desc = None return
def area_update(): for area_id, area in instance.areas.items(): area.age += 1 if area.age < 3: continue # # * Check age and reset. #* Note: Mud School resets every 3 minutes (not 15). #*/ if (not area.empty and (area.character == 0 or area.age >= 15)) or area.age >= 31: reset_area(area) handler_game.wiznet("%s has just been reset." % area.name, None, None, merc.WIZ_RESETS, 0, 0) area.age = random.randint(0, 3) school_instance_id = instance.instances_by_room[merc.ROOM_VNUM_SCHOOL][0] school_instance = instance.rooms[school_instance_id] if school_instance and area_id == school_instance.area: area.age = 15 - 2 elif area.player_count == 0: area.empty = True
def do_noemote(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Noemote whom?\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim.trust >= ch.trust: ch.send("You failed.\n") return if victim.comm.is_set(merc.COMM_NOEMOTE): victim.comm = state_checks.REMOVE_BIT(victim.comm, merc.COMM_NOEMOTE) victim.send("You can emote again.\n") ch.send("NOEMOTE removed.\n") handler_game.wiznet("$N restores emotes to %s." % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) else: victim.comm = state_checks.SET_BIT(victim.comm, merc.COMM_NOEMOTE) victim.send("You can't emote!\n") ch.send("NOEMOTE set.\n") handler_game.wiznet("$N revokes %s's emotes." % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) return
def do_deny(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Deny whom?\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim.is_npc(): ch.send("Not on NPC's.\n") return if victim.trust >= ch.trust: ch.send("You failed.\n") return victim.act = state_checks.SET_BIT(victim.act, merc.PLR_DENY) victim.send("You are denied access!\n") handler_game.wiznet("$N denies access to %s" % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0) ch.send("OK.\n") victim.save(logout=True, force=True) fight.stop_fighting(victim, True) victim.do_quit("") return
def area_update(): for area_id, area in instance.areas.items(): area.age += 1 if area.age < 3: continue # # * Check age and reset. #* Note: Mud School resets every 3 minutes (not 15). #*/ if (not area.empty and (area.character == 0 or area.age >= 15)) or area.age >= 31: reset_area(area) handler_game.wiznet("%s has just been reset." % area.name, None, None, merc.WIZ_RESETS, 0, 0) area.age = random.randint(0, 3) school_instance_id = instance.instances_by_room[ merc.ROOM_VNUM_SCHOOL][0] school_instance = instance.rooms[school_instance_id] if school_instance and area_id == school_instance.area: area.age = 15 - 2 elif area.player_count == 0: area.empty = True
def con_get_new_class(self): argument = self.get_command() ch = self.character guild = state_checks.prefix_lookup(const.guild_table, argument) if not guild: ch.send("That's not a class.\nWhat IS your class? ") return ch.guild = guild ch_selections['guild'] = guild log_buf = "%s@%s new player." % (ch.name, self.addrport()) logger.info(log_buf) handler_game.wiznet("Newbie alert! $N sighted.", ch, None, merc.WIZ_NEWBIE, 0, 0) handler_game.wiznet(log_buf, None, None, merc.WIZ_SITES, 0, ch.trust) ch.send("\nYou may be good, neutral, or evil.\n") ch.send("Which alignment (G/N/E)? ") self.set_connected(con_get_alignment) return
def interpret(self, argument): # Strip leading spaces. argument = argument.lstrip() # No hiding. self.affected_by.rem_bit(merc.AFF_HIDE) # Implement freeze command. if not self.is_npc() and self.act.is_set(merc.PLR_FREEZE): self.send("You're totally frozen!\n") return # Grab the command word. # Special parsing so ' can be a command, # also no spaces needed after punctuation. logline = argument if not argument[0].isalpha() and not argument[0].isdigit(): command = argument[0] argument = argument[:1].lstrip() else: argument, command = game_utils.read_word(argument) # Look for command in command table. trust = self.trust cmd = state_checks.prefix_lookup(interp.cmd_table, command) if cmd is not None: if cmd.level > trust: cmd = None #* Log and snoop. if (not self.is_npc() and self.act.is_set(merc.PLR_LOG)) \ or settings.LOGALL \ or (cmd and cmd.log == merc.LOG_ALWAYS): if cmd and cmd.log != merc.LOG_NEVER: log_buf = "Log %s: %s" % (self.name, logline) handler_game.wiznet(log_buf, self, None, merc.WIZ_SECURE, 0, self.trust) logger.info(log_buf) if self.desc and self.desc.snoop_by: self.desc.snoop_by.send("% ") self.desc.snoop_by.send(logline) self.desc.snoop_by.send("\n") if not cmd: #* Look for command in socials table. if not Pc.check_social(self, command, argument): if settings.DETAILED_INVALID_COMMANDS: #TODO: Levenshtein distance over cmd_table, also add a wait_state to prevent horrors self.send("Huh? '%s' is not a valid command." % command) else: self.send("Huh?\n") return #* Pc not in position for command? if self.position < cmd.position: if self.position == merc.POS_DEAD: self.send("Lie still; you are DEAD.\n") elif self.position == merc.POS_MORTAL \ or self.position == merc.POS_INCAP: self.send("You are hurt far too bad for that.\n") elif self.position == merc.POS_STUNNED: self.send("You are too stunned to do that.\n") elif self.position == merc.POS_SLEEPING: self.send("In your dreams, or what?\n") elif self.position == merc.POS_RESTING: self.send("Nah... You feel too relaxed...\n") elif self.position == merc.POS_SITTING: self.send("Better stand up first.\n") elif self.position == merc.POS_FIGHTING: self.send("No way! You are still fighting!\n") return # Dispatch the command. if cmd.default_arg: cmd.do_fun(self, cmd.default_arg) return cmd.do_fun(self, argument.lstrip())
def do_clone(ch, argument): rest, arg = game_utils.read_word(argument) mob = None obj = None if not arg: ch.send("Clone what?\n") return if "object".startswith(arg): mob = None obj = ch.get_item_here(rest) if not obj: ch.send("You don't see that here.\n") return elif "character".startswith(arg) or "mobile".startswith(arg): obj = None mob = ch.get_char_room(rest) if not mob: ch.send("You don't see that here.\n") return else: # find both mob = ch.get_char_room(argument) obj = ch.get_item_here(argument) if mob is None and obj is None: ch.send("You don't see that here.\n") return # clone an object if obj: if not handler_item.item_check(ch, obj): ch.send("Your powers are not great enough for such a task.\n") return clone = object_creator.create_item(obj.vnum, 0) object_creator.clone_item(obj, clone) if obj.in_living: clone.put(ch) else: clone.put(ch.in_room) handler_item.recursive_clone(ch, obj, clone) handler_game.act("$n has created $p.", ch, clone, None, merc.TO_ROOM) handler_game.act("You clone $p.", ch, clone, None, merc.TO_CHAR) handler_game.wiznet("$N clones $p.", ch, clone, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust) return elif mob: if not state_checks.IS_NPC(mob): ch.send("You can only clone mobiles.\n") return if (mob.level > 20 and not state_checks.IS_TRUSTED(ch, merc.L4)) \ or (mob.level > 10 and not state_checks.IS_TRUSTED(ch, merc.L5)) \ or (mob.level > 5 and not state_checks.IS_TRUSTED(ch, merc.L6)) \ or (mob.level > 0 and not state_checks.IS_TRUSTED(ch, merc.L7)) \ or not state_checks.IS_TRUSTED(ch, merc.L8): ch.send("Your powers are not great enough for such a task.\n") return clone = object_creator.create_mobile(mob.vnum) object_creator.clone_mobile(mob, clone) for obj in mob.contents: if handler_item.item_check(ch, obj): new_obj = object_creator.create_item(obj.vnum, 0) object_creator.clone_item(obj, new_obj) handler_item.recursive_clone(ch, obj, new_obj) new_obj.put(clone) new_obj.equips_to = obj.equips_to clone.put(ch.in_room) handler_game.act("$n has created $N.", ch, None, clone, merc.TO_ROOM) handler_game.act("You clone $N.", ch, None, clone, merc.TO_CHAR) handler_game.wiznet("$N clones %s." % clone.short_descr, ch, None, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust) return
def con_read_motd(self): ch = self.character if not ch.pwd: ch.send("Warning! Null password!\n") ch.send("Please report old password with bug.\n") ch.send("Type 'password null <new password>' to fix.\n") ch.send("\nWelcome to ROM 2.4. Please do not feed the mobiles.\n") ch.reset() self.set_connected(con_playing) if ch.level == 0: ch.perm_stat[ch.guild.attr_prime] += 3 ch.position = merc.POS_STANDING ch.level = 1 ch.exp = ch.exp_per_level(ch.points) ch.hit = ch.max_hit ch.mana = ch.max_mana ch.move = ch.max_move ch.train = 3 ch.practice = 5 buf = "the %s" % const.title_table[ch.guild.name][ch.level][ch.sex - 1] ch.title = buf #ch.prompt = "<%hhp %mm %vmv> " ch.do_outfit(ch_selections['weapon']) ch.put( object_creator.create_item( instance.item_templates[merc.OBJ_VNUM_MAP], 0)) school_id = instance.instances_by_room[merc.ROOM_VNUM_SCHOOL][0] school = instance.rooms[school_id] school.put(ch) ch.do_help("newbie info") #TODO: create a player manifest that we can use/check, instead of needing to walk the dir. player_files = os.listdir(settings.PLAYER_DIR) if len(player_files) < 1: for iLevel in range(ch.level, merc.MAX_LEVEL): ch.level += 1 update.advance_level(ch, True) ch.exp = ch.exp_per_level(ch.points) * max(1, ch.level) ch.trust = 0 ch.save() ch.send( '\n\nCongratulations! As the first player to log into this MUD, you are now\n' + 'the IMPLEMENTOR, the sucker in charge, the place where the buck stops.\n' + 'Enjoy!\n\n') if ch._environment in instance.global_instances.keys( ) and not ch.level == 0: room = instance.global_instances.get(ch._environment, None) if room and ch._environment != room.instance_id: room.put(ch) elif ch.is_immortal() and not ch.level == 0: to_instance_id = instance.instances_by_room[merc.ROOM_VNUM_CHAT][0] to_instance = instance.rooms[to_instance_id] to_instance.put(ch) else: to_instance_id = instance.instances_by_room[merc.ROOM_VNUM_TEMPLE][0] to_instance = instance.rooms[to_instance_id] to_instance.put(ch) handler_game.act("$n has entered the game.", ch, None, None, merc.TO_ROOM) ch.do_look("auto") ch.send("\n\n") ch.do_term("") handler_game.wiznet("$N has left real life behind.", ch, None, merc.WIZ_LOGINS, merc.WIZ_SITES, ch.trust) if ch.pet: ch.in_room.put(ch.pet) handler_game.act("$n has entered the game.", ch.pet, None, None, merc.TO_ROOM)
def do_steal(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Steal what from whom?\n") return victim = ch.get_char_room(arg2) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("That's pointless.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.position == merc.POS_FIGHTING: ch.send( "Kill stealing is not permitted.\nYou'd better not -- you might get hit.\n" ) return state_checks.WAIT_STATE(ch, const.skill_table["steal"].beats) percent = random.randint(1, 99) if not state_checks.IS_AWAKE(victim): percent -= 10 elif not victim.can_see(ch): percent += 25 else: percent += 50 if ((ch.level + 7 < victim.level or ch.level - 7 > victim.level) and not victim.is_npc() and not ch.is_npc() ) \ or (not ch.is_npc() and percent > ch.get_skill("steal")) \ or (not ch.is_npc() and not ch.is_clan()): # Failure. ch.send("Oops.\n") ch.affect_strip("sneak") ch.affected_by = ch.affected_by.rem_bit(merc.AFF_SNEAK) handler_game.act("$n tried to steal from you.\n", ch, None, victim, merc.TO_VICT) handler_game.act("$n tried to steal from $N.\n", ch, None, victim, merc.TO_NOTVICT) outcome = random.randint(0, 3) buf = '' if outcome == 0: buf = "%s is a lousy thief!" % ch.name elif outcome == 1: buf = "%s couldn't rob %s way out of a paper bag!" % (ch.name, ( "her" if ch.sex == 2 else "his")) elif outcome == 2: buf = "%s tried to rob me!" % ch.name elif outcome == 3: buf = "Keep your hands out of there, %s!" % ch.name if not state_checks.IS_AWAKE(victim): victim.do_wake("") if state_checks.IS_AWAKE(victim): victim.do_yell(buf) if not ch.is_npc(): if victim.is_npc(): if ch.is_pc(): ch.check_improve("steal", False, 2) fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) else: handler_game.wiznet("$N tried to steal from %s." % victim.name, ch, None, merc.WIZ_FLAGS, 0, 0) if not ch.act.is_set(merc.PLR_THIEF): ch.act.set_bit(merc.PLR_THIEF) ch.send("*** You are now a THIEF!! ***\n") ch.save() return currency = ['coins', 'coin', 'gold', 'silver'] if arg1 in currency: gold = victim.gold * random.randint(1, ch.level) // merc.MAX_LEVEL silver = victim.silver * random.randint(1, ch.level) // merc.MAX_LEVEL if gold <= 0 and silver <= 0: ch.send("You couldn't get any coins.\n") return ch.gold += gold ch.silver += silver victim.silver -= silver victim.gold -= gold if silver <= 0: ch.send("Bingo! You got %d gold coins.\n" % gold) elif gold <= 0: ch.send("Bingo! You got %d silver coins.\n" % silver) else: ch.send("Bingo! You got %d silver and %d gold coins.\n" % (silver, gold)) if ch.is_pc(): ch.check_improve("steal", True, 2) return item = victim.get_item_carry(arg1, ch) if not item: ch.send("You can't find it.\n") return if not ch.can_drop_item( item) or item.flags.shop_inventory or item.level > ch.level: ch.send("You can't pry it away.\n") return if ch.carry_number + item.get_number() > ch.can_carry_n(): ch.send("You have your hands full.\n") return if ch.carry_weight + item.get_weight() > ch.can_carry_w(): ch.send("You can't carry that much weight.\n") return item.get() ch.put(item) handler_game.act("You pocket $p.", ch, item, None, merc.TO_CHAR) if ch.is_pc(): ch.check_improve("steal", True, 2) ch.send("Got it!\n") return
def do_steal(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Steal what from whom?\n") return victim = ch.get_char_room(arg2) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("That's pointless.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.position == merc.POS_FIGHTING: ch.send("Kill stealing is not permitted.\nYou'd better not -- you might get hit.\n") return state_checks.WAIT_STATE(ch, const.skill_table["steal"].beats) percent = random.randint(1, 99) if not state_checks.IS_AWAKE(victim): percent -= 10 elif not victim.can_see(ch): percent += 25 else: percent += 50 if ((ch.level + 7 < victim.level or ch.level - 7 > victim.level) and not victim.is_npc() and not ch.is_npc() ) \ or (not ch.is_npc() and percent > ch.get_skill("steal")) \ or (not ch.is_npc() and not ch.is_clan()): # Failure. ch.send("Oops.\n") ch.affect_strip("sneak") ch.affected_by = ch.affected_by.rem_bit(merc.AFF_SNEAK) handler_game.act("$n tried to steal from you.\n", ch, None, victim, merc.TO_VICT) handler_game.act("$n tried to steal from $N.\n", ch, None, victim, merc.TO_NOTVICT) outcome = random.randint(0, 3) buf = '' if outcome == 0: buf = "%s is a lousy thief!" % ch.name elif outcome == 1: buf = "%s couldn't rob %s way out of a paper bag!" % (ch.name, ("her" if ch.sex == 2 else "his")) elif outcome == 2: buf = "%s tried to rob me!" % ch.name elif outcome == 3: buf = "Keep your hands out of there, %s!" % ch.name if not state_checks.IS_AWAKE(victim): victim.do_wake("") if state_checks.IS_AWAKE(victim): victim.do_yell(buf) if not ch.is_npc(): if victim.is_npc(): if ch.is_pc(): ch.check_improve("steal", False, 2) fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) else: handler_game.wiznet("$N tried to steal from %s." % victim.name, ch, None, merc.WIZ_FLAGS, 0, 0) if not ch.act.is_set(merc.PLR_THIEF): ch.act.set_bit(merc.PLR_THIEF) ch.send("*** You are now a THIEF!! ***\n") ch.save() return currency = ['coins', 'coin', 'gold', 'silver'] if arg1 in currency: gold = victim.gold * random.randint(1, ch.level) // merc.MAX_LEVEL silver = victim.silver * random.randint(1, ch.level) // merc.MAX_LEVEL if gold <= 0 and silver <= 0: ch.send("You couldn't get any coins.\n") return ch.gold += gold ch.silver += silver victim.silver -= silver victim.gold -= gold if silver <= 0: ch.send("Bingo! You got %d gold coins.\n" % gold) elif gold <= 0: ch.send("Bingo! You got %d silver coins.\n" % silver) else: ch.send("Bingo! You got %d silver and %d gold coins.\n" % (silver, gold)) if ch.is_pc(): ch.check_improve( "steal", True, 2) return item = victim.get_item_carry(arg1, ch) if not item: ch.send("You can't find it.\n") return if not ch.can_drop_item(item) or item.flags.shop_inventory or item.level > ch.level: ch.send("You can't pry it away.\n") return if ch.carry_number + item.get_number() > ch.can_carry_n(): ch.send("You have your hands full.\n") return if ch.carry_weight + item.get_weight() > ch.can_carry_w(): ch.send("You can't carry that much weight.\n") return item.get() ch.put(item) handler_game.act("You pocket $p.", ch, item, None, merc.TO_CHAR) if ch.is_pc(): ch.check_improve( "steal", True, 2) ch.send("Got it!\n") return