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_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_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 find_spell(ch, name): # finds a spell the character can cast if possible from const import skill_table found = None if ch.is_npc(): return state_checks.prefix_lookup(skill_table, name) for key, sn in skill_table.items(): if key.startswith(name.lower()): if not found: found = sn if ch.level >= sn.skill_level and key in ch.learned: return sn return found
def find_spell(ch, name): #* finds a spell the character can cast if possible */ from const import skill_table found = None if ch.is_npc(): return state_checks.prefix_lookup(skill_table,name) for key, sn in skill_table.items(): if key.startswith(name.lower()): if found == None: found = sn if ch.level >= sn.skill_level[ch.guild.name] and key in ch.learned: return sn return found
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_slookup(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Lookup which skill or spell?\n") return if arg == "all": for sn, skill in const.skill_table.items(): ch.send("Sn: %15s Slot: %3d Skill/spell: '%s'\n" % (sn, skill.slot, skill.name)) else: skill = state_checks.prefix_lookup(const.skill_table, arg) if not skill: ch.send("No such skill or spell.\n") return ch.send("Sn: %15s Slot: %3d Skill/spell: '%s'\n" % (skill.name, skill.slot, skill.name))
def do_wiznet(ch, argument): if not argument: if state_checks.IS_SET(ch.wiznet, merc.WIZ_ON): ch.send("Signing off of Wiznet.\n") ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, merc.WIZ_ON) else: ch.send("Welcome to Wiznet!\n") ch.wiznet = state_checks.SET_BIT(ch.wiznet, merc.WIZ_ON) return if "on".startswith(argument): ch.send("Welcome to Wiznet!\n") ch.wiznet = state_checks.SET_BIT(ch.wiznet, merc.WIZ_ON) return if "off".startswith(argument): ch.send("Signing off of Wiznet.\n") ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, merc.WIZ_ON) return buf = '' # show wiznet status if "status".startswith(argument): if not state_checks.IS_SET(ch.wiznet, merc.WIZ_ON): buf += "off " for name, flag in const.wiznet_table.items(): if state_checks.IS_SET(ch.wiznet, flag.bit): buf += name + " " ch.send("Wiznet status:\n%s\n" % buf) return if "show".startswith(argument): # list of all wiznet options buf = '' for name, flag in const.wiznet_table.items(): if flag.level <= ch.trust: buf += name + " " ch.send("Wiznet options available to you are:\n%s\n" % buf) return flag = state_checks.prefix_lookup(const.wiznet_table, argument) if not flag or ch.trust < flag.level: ch.send("No such option.\n") return if state_checks.IS_SET(ch.wiznet, flag.bit): ch.send("You will no longer see %s on wiznet.\n" % flag.name) ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, flag.bit) return else: ch.send("You will now see %s on wiznet.\n" % flag.name) ch.wiznet = state_checks.SET_BIT(ch.wiznet, flag.bit) return
def do_wiznet(ch, argument): if not argument: if state_checks.IS_SET(ch.wiznet, merc.WIZ_ON): ch.send("Signing off of Wiznet.\n") ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, merc.WIZ_ON) else: ch.send("Welcome to Wiznet!\n") ch.wiznet = state_checks.SET_BIT(ch.wiznet, merc.WIZ_ON) return if "on".startswith(argument): ch.send("Welcome to Wiznet!\n") ch.wiznet = state_checks.SET_BIT(ch.wiznet, merc.WIZ_ON) return if "off".startswith(argument): ch.send("Signing off of Wiznet.\n") ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, merc.WIZ_ON) return buf = '' # show wiznet status if "status".startswith(argument): if not state_checks.IS_SET(ch.wiznet, merc.WIZ_ON): buf += "off " for name, flag in const.wiznet_table.items(): if state_checks.IS_SET(ch.wiznet, flag.bit): buf += name + " " ch.send("Wiznet status:\n%s\n" % buf) return if "show".startswith(argument): # list of all wiznet options buf = '' for name, flag in const.wiznet_table.items(): if flag.level <= ch.trust: buf += name + " " ch.send("Wiznet options available to you are:\n%s\n" % buf) return flag = state_checks.prefix_lookup(const.wiznet_table, argument) if not flag or ch.trust < flag.level: ch.send("No such option.\n") return if state_checks.IS_SET(ch.wiznet, flag.bit): ch.send("You will no longer see %s on wiznet.\n" % flag.name) ch.wiznet = state_checks.REMOVE_BIT(ch.wiznet, flag.bit) return else: ch.send("You will now see %s on wiznet.\n" % flag.name) ch.wiznet = state_checks.SET_BIT(ch.wiznet, flag.bit) return
def con_pick_weapon(self): argument = self.get_command() ch = self.character weapon = state_checks.prefix_lookup(const.weapon_table, argument) if not weapon or ch.learned[weapon.gsn] <= 0: ch.send("That's not a valid selection. Choices are:\n") for k, weapon in const.weapon_table.items(): if weapon.gsn in ch.learned: ch.send("%s " % weapon.name) ch.send("\nYour choice? ") return ch.learned[weapon.gsn] = 40 ch_selections['weapon'] = weapon.gsn ch.do_help("motd") self.set_connected(con_read_motd)
def con_get_new_race(self): global ch_selections argument = self.get_command().lower() ch = self.character if argument.startswith("help"): argument, arg = game_utils.read_word(argument) if not argument: ch.do_help('race help') else: ch.do_help(argument) ch.send("\nWhat is your race (help for more information)? ") return race = state_checks.prefix_lookup(const.pc_race_table, argument) if not race: ch.send("That is not a valid race.\n") ch.send("The following races are available:\n ") for race in const.pc_race_table: ch.send("%s " % const.race_table[race].name) ch.send("\nWhat is your race? (help for more information) ") return ch.race = const.race_table[race.name] ch_selections['race'] = race.name #initialize stats */ for i in range(merc.MAX_STATS): ch.perm_stat[i] = race.stats[i] ch.affected_by.set_bit(const.race_table[race.name].aff) ch.imm_flags.set_bit(const.race_table[race.name].imm) ch.res_flags.set_bit(const.race_table[race.name].res) ch.vuln_flags.set_bit(const.race_table[race.name].vuln) ch.form.set_bit(const.race_table[race.name].form) ch.parts.set_bit(const.race_table[race.name].parts) # add skills */ for i in race.skills: ch.group_add(i, False) # add cost */ ch.points = race.points ch.size = race.size ch.send("What is your sex (M/F)? ") self.set_connected(con_get_new_sex) return
def do_slookup(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Lookup which skill or spell?\n") return if arg == "all": for sn, skill in const.skill_table.items(): ch.send("Sn: %15s Slot: %3d Skill/spell: '%s'\n" % (sn, skill.slot, skill.name)) else: skill = state_checks.prefix_lookup(const.skill_table, arg) if not skill: ch.send("No such skill or spell.\n") return ch.send("Sn: %15s Slot: %3d Skill/spell: '%s'\n" % (skill.name, skill.slot, skill.name))
def cmd_slookup(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Slookup what?\n") return if game_utils.str_cmp(arg, "all"): buf = [] for sn, skill in const.skill_table.items(): buf += "Sn: {:15} Slot: {:4} Skill/spell: '{}'\n".format(sn, skill.slot, skill.name) ch.send("".join(buf)) else: skill = state_checks.prefix_lookup(const.skill_table, arg) if not skill: ch.send("No such skill or spell.\n") return ch.send("Sn: {:15} Slot: {:4} Skill/spell: '{}'\n".format(skill.name, skill.slot, skill.name))
def do_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:\n") ch.send(" set skill <name> <spell or skill> <value>\n") ch.send(" set skill <name> all <value>\n") ch.send(" (use the name of the skill, not the number)\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 fAll = 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 < 0 or value > 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("Skill set.\n")
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 cmd_practice(ch, argument): temp, argument = game_utils.read_word(argument) if ch.is_npc(): return if not argument: buf = [] col = 0 ch.update_skills() for sn, skill in const.skill_table.items(): if sn not in ch.learned: continue buf += "{:<18} {:3}% ".format(skill.name, ch.learned[sn]) col += 1 if col % 3 == 0: buf += "\n" if col % 3 != 0: buf += "\n" buf += "You have {:,} exp left.\n".format(ch.exp) ch.send("".join(buf)) else: if not ch.is_awake(): ch.send("In your dreams, or what?\n") return if ch.exp <= 0: ch.send("You have no exp 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.send("You can't practice that.\n") return if ch.learned[skill.name] >= 100: ch.send("You are already an adept of {}.\n".format(skill.name)) elif ch.learned[skill.name] > 0 and (ch.learned[skill.name] // 2) > ch.exp: ch.send("You need {} exp to increase {} any more.\n".format( ch.learned[skill.name] // 2, skill.name)) elif ch.learned[skill.name] == 0 and ch.exp < 500: ch.send("You need 500 exp to increase {}.\n".format(skill.name)) else: if ch.learned[skill.name] == 0: ch.exp -= 500 ch.learned[skill.name] += ch.stat(merc.STAT_INT) else: ch.exp -= ch.learned[skill.name] // 2 ch.learned[skill.name] += const.int_app[ch.stat( merc.STAT_INT)].learn if ch.learned[skill.name] < 100: handler_game.act("You practice $T.", ch, None, skill.name, merc.TO_CHAR) else: ch.learned[skill.name] = 100 handler_game.act("You are now an adept of $T.", ch, None, skill.name, merc.TO_CHAR)
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 interpret(self, argument): # Strip leading spaces. argument = argument.lstrip() if not argument: return # Implement freeze command. if not self.is_npc() and self.sentances.is_set(merc.SENT_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: if command[0] == cmd.name[0] and game_utils.str_prefix( command, cmd.name) and cmd.level <= trust: if self.head.is_set(merc.LOST_HEAD) or self.extra.is_set( merc.EXTRA_OSWITCH): cmd_list = [ "say", "'", "immtalk", ":", "chat" ".", "look", "save", "exits", "emote", "tell", "order", "who", "weather", "where", "relevel", "safe", "scan", "say", "spy", "score", "save", "inventory", "oreturn", "roll", "leap", "lifespan", "nightsight", "truesight", "horns", "fangs", "cast" ] if game_utils.str_cmp(cmd.name, cmd_list) or ( game_utils.str_cmp(cmd.name, ["quit", "humanform"]) and not self.is_npc() and self.obj_vnum != 0): pass else: self.send("Not without a body!\n") return elif self.extra.is_set(merc.EXTRA_TIED_UP): cmd_list = [ "say", "'", "chat", ".", "yell", "shout", "look", "save", "exits", "inventory", "tell", "order", "who", "weather", "where", "introduce", "relevel", "safe", "scan", "spy", "wake", "fangs", "claws", "nightsight", "shadowsight", "shadowplane", "regenerate", "shield", "vclan", "upkeep", "score", "immune", "report", "goto", "flex", "change", "drink" ] if game_utils.str_cmp(cmd.name, cmd_list): pass else: self.send("Not while tied up.\n") if self.position > merc.POS_STUNNED: handler_game.act("$n strains against $s bonds.", self, None, None, merc.TO_ROOM) return else: cmd = None # Log and snoop. if cmd and cmd.log == merc.LOG_NEVER: logline = "XXXXXXXX XXXXXXXX XXXXXXXX" if (not self.is_npc() and self.sentances.is_set(merc.SENT_LOG) ) or settings.LOGALL or (cmd and cmd.log == merc.LOG_ALWAYS): comm.notify("{}: {}".format(self.name, logline), merc.CONSOLE_INFO) if self.desc and self.desc.snoop_by: self.desc.snoop_by.send("% " + logline + "\n") if not cmd: # Look for command in socials table. if not Pc.check_social(self, command, argument): self.huh() 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 in [merc.POS_MORTAL, 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 in [ merc.POS_MEDITATING, merc.POS_SITTING, merc.POS_RESTING ]: self.send("Nah... You feel too relaxed...\n") elif self.position == merc.POS_FIGHTING: self.send("No way! You are still fighting!\n") return # Dispatch the command. cmd.cmd_fun(self, cmd.default_arg if cmd.default_arg else argument.lstrip())
def cmd_stake(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return if not arg: ch.send("Stake whom?\n") return stake = ch.get_eq("right_hand") if not stake or stake.item_type != merc.ITEM_STAKE: stake = ch.get_eq("left_hand") if not stake or stake.item_type != merc.ITEM_STAKE: ch.send("How can you stake someone down without holding a stake?\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if victim.is_npc(): ch.not_npc() return if ch == victim: ch.not_self() return if not victim.is_vampire(): ch.send("You can only stake vampires.\n") return if victim.position > merc.POS_MORTAL: ch.send("You can only stake down a vampire who is mortally wounded.\n") return handler_game.act("You plunge $p into $N's heart.", ch, stake, victim, merc.TO_CHAR) handler_game.act("$n plunges $p into $N's heart.", ch, stake, victim, merc.TO_NOTVICT) victim.send("You feel a stake plunged through your heart.\n") if victim.immune.is_set(merc.IMM_STAKE): return # Have to make sure they have enough blood to change back blood = victim.blood victim.blood = 666 # To take care of vampires who have powers in affect. if victim.vampaff.is_set(merc.VAM_DISGUISED): victim.cmd_mask("self") if victim.immune.is_set(merc.IMM_SHIELDED): victim.cmd_shield("") if victim.is_affected(merc.AFF_SHADOWPLANE): victim.cmd_shadowplane("") if victim.vampaff.is_set(merc.VAM_FANGS): victim.cmd_fangs("") if victim.vampaff.is_set(merc.VAM_CLAWS): victim.cmd_claws("") if victim.vampaff.is_set(merc.VAM_NIGHTSIGHT): victim.cmd_nightsight("") if victim.is_affected(merc.AFF_SHADOWSIGHT): victim.cmd_shadowsight("") if victim.act.is_set(merc.PLR_HOLYLIGHT): victim.cmd_truesight("") if victim.vampaff.is_set(merc.VAM_CHANGED): victim.cmd_change("human") if victim.polyaff.is_set(merc.POLY_SERPENT): victim.cmd_serpent("") victim.powers[merc.UNI_RAGE] = 0 victim.blood = blood victim.ch_class = state_checks.prefix_lookup(const.class_table, "human") ch.get(stake) victim.put(stake) ch.exp += 1000 victim.home = merc.ROOM_VNUM_TEMPLE
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_mset(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:\n") ch.send(" set char <name> <field> <value>\n") ch.send(" Field being one of:\n") ch.send(" str int wis dex con sex class level\n") ch.send(" race group gold silver hp mana move prac\n") ch.send(" align train thirst hunger drunk full\n") return victim = ch.get_char_world(arg1) if not victim: ch.send("They aren't here.\n") return # clear zones for mobs victim.zone = None # Snarf the value (which need not be numeric). value = int(arg3) if arg3.isdigit() else -1 # Set something. if arg2 == "str": if value < 3 or value > victim.get_max_train(merc.STAT_STR): ch.send("Strength range is 3 to %d\n." % victim.get_max_train(merc.STAT_STR)) return victim.perm_stat[merc.STAT_STR] = value ch.send("Str set to %d.\n" % value) return if arg2 == "int": if value < 3 or value > victim.get_max_train(merc.STAT_INT): ch.send("Intelligence range is 3 to %d.\n" % victim.get_max_train(merc.STAT_INT)) return ch.send("Int set to %d.\n" % value) victim.perm_stat[merc.STAT_INT] = value return if arg2 == "wis": if value < 3 or value > victim.get_max_train(merc.STAT_WIS): ch.send("Wisdom range is 3 to %d.\n" % victim.get_max_train(merc.STAT_WIS)) return victim.perm_stat[merc.STAT_WIS] = value return if arg2 == "dex": if value < 3 or value > victim.get_max_train(merc.STAT_DEX): ch.send("Dexterity range is 3 to %d.\n" % victim.get_max_train(merc.STAT_DEX)) return ch.send("Dex set to %d.\n" % value) victim.perm_stat[merc.STAT_DEX] = value return if arg2 == "con": if value < 3 or value > victim.get_max_train(merc.STAT_CON): ch.send("Constitution range is 3 to %d.\n" % victim.get_max_train(merc.STAT_CON)) return ch.send("Con set to %d.\n" % value) victim.perm_stat[merc.STAT_CON] = value return if "sex".startswith(arg2): if value < 0 or value > 2: ch.send("Sex range is 0 to 2.\n") return victim.sex = value if not victim.is_npc(): victim.true_sex = value ch.send("Sex set to %s.\n" % tables.sex_table[value]) return if "class".startswith(arg2): if victim.is_npc(): ch.send("Mobiles have no class.\n") return guild = state_checks.prefix_lookup(const.guild_table, arg3) if not guild: ch.send("Possible classes are: ") for guild in const.guild_table.keys(): ch.send("%s " % guild) ch.send(".\n") return ch.send("Guild set to %s\n" % guild.name) victim.guild = guild return if "level".startswith(arg2): if not victim.is_npc(): ch.send("Not on PC's.\n") return if value < 0 or value > merc.MAX_LEVEL: ch.send("Level range is 0 to %d.\n" % merc.MAX_LEVEL) return ch.send("Level set to %d.\n" % value) victim.level = value return if "gold".startswith(arg2): victim.gold = value ch.send("Gold set to %d\n" % victim.gold) return if "silver".startswith(arg2): victim.silver = value ch.send("Silver set to %d\n" % victim.silver) return if "hp".startswith(arg2): if value < -10 or value > 30000: ch.send("Hp range is -10 to 30,000 hit points.\n") return victim.max_hit = value ch.send("Max Hitpoints set to %d\n" % value) if not victim.is_npc(): victim.perm_hit = value return if "mana".startswith(arg2): if value < 0 or value > 30000: ch.send("Mana range is 0 to 30,000 mana points.\n") return victim.max_mana = value ch.send("Max Mana set to %d\n" % value) if not victim.is_npc(): victim.perm_mana = value return if "move".startswith(arg2): if value < 0 or value > 30000: ch.send("Move range is 0 to 30,000 move points.\n") return victim.max_move = value ch.send("Max Move set to %d.\n" % value) if not victim.is_npc(): victim.perm_move = value return if "practice".startswith(arg2): if value < 0 or value > 250: ch.send("Practice range is 0 to 250 sessions.\n") return victim.practice = value ch.send("Victims practices set to %d.\n" % value) return if "train".startswith(arg2): if value < 0 or value > 50: ch.send("Training session range is 0 to 50 sessions.\n") return victim.train = value ch.send("Trains set to %d.\n" % value) return if "align".startswith(arg2): if value < -1000 or value > 1000: ch.send("Alignment range is -1000 to 1000.\n") return victim.alignment = value ch.send("Alignment set to %d.\n" % value) return if "thirst".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Thirst range is -1 to 100.\n") return victim.condition[merc.COND_THIRST] = value ch.send("Victims thirst set to %d.\n" % value) return if "drunk".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Drunk range is -1 to 100.\n") return victim.condition[merc.COND_DRUNK] = value ch.send("Victims Drunk set to %d.\n" % value) return if "full".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Full range is -1 to 100.\n") return ch.send("Full condition set to %d\n" % value) victim.condition[merc.COND_FULL] = value return if "hunger".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Full range is -1 to 100.\n") return ch.send("Hunger set to %d.\n" % value) victim.condition[merc.COND_HUNGER] = value return if "race".startswith(arg2): race = state_checks.prefix_lookup(const.race_table, arg3) if not race: ch.send("That is not a valid race.\n") return if not victim.is_npc() and race.name not in const.pc_race_table: ch.send("That is not a valid player race.\n") return ch.send("Race set to %s.\n" % race.name) victim.race = race return if "group".startswith(arg2): if not victim.is_npc(): ch.send("Only on NPCs.\n") return victim.group = value return # Generate usage message. ch.do_mset("")
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_mset(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:\n") ch.send(" set char <name> <field> <value>\n") ch.send(" Field being one of:\n") ch.send(" str int wis dex con sex class level\n") ch.send(" race group gold silver hp mana move prac\n") ch.send(" align train thirst hunger drunk full\n") return victim = ch.get_char_world(arg1) if not victim: ch.send("They aren't here.\n") return # clear zones for mobs victim.zone = None # Snarf the value (which need not be numeric). value = int(arg3) if arg3.isdigit() else -1 # Set something. if arg2 == "str": if value < 3 or value > victim.get_max_train(merc.STAT_STR): ch.send("Strength range is 3 to %d\n." % victim.get_max_train(merc.STAT_STR)) return victim.perm_stat[merc.STAT_STR] = value ch.send("Str set to %d.\n" % value) return if arg2 == "int": if value < 3 or value > victim.get_max_train(merc.STAT_INT): ch.send("Intelligence range is 3 to %d.\n" % victim.get_max_train(merc.STAT_INT)) return ch.send("Int set to %d.\n" % value) victim.perm_stat[merc.STAT_INT] = value return if arg2 == "wis": if value < 3 or value > victim.get_max_train(merc.STAT_WIS): ch.send("Wisdom range is 3 to %d.\n" % victim.get_max_train(merc.STAT_WIS)) return victim.perm_stat[merc.STAT_WIS] = value return if arg2 == "dex": if value < 3 or value > victim.get_max_train(merc.STAT_DEX): ch.send("Dexterity range is 3 to %d.\n" % victim.get_max_train(merc.STAT_DEX)) return ch.send("Dex set to %d.\n" % value) victim.perm_stat[merc.STAT_DEX] = value return if arg2 == "con": if value < 3 or value > victim.get_max_train(merc.STAT_CON): ch.send("Constitution range is 3 to %d.\n" % victim.get_max_train(merc.STAT_CON)) return ch.send("Con set to %d.\n" % value) victim.perm_stat[merc.STAT_CON] = value return if "sex".startswith(arg2): if value < 0 or value > 2: ch.send("Sex range is 0 to 2.\n") return victim.sex = value if not victim.is_npc(): victim.true_sex = value ch.send("Sex set to %s.\n" % tables.sex_table[value]) return if "class".startswith(arg2): if victim.is_npc(): ch.send("Mobiles have no class.\n") return guild = state_checks.prefix_lookup(const.guild_table, arg3) if not guild: ch.send("Possible classes are: ") for guild in const.guild_table.keys(): ch.send("%s " % guild) ch.send(".\n") return ch.send("Guild set to %s\n" % guild.name) victim.guild = guild return if "level".startswith(arg2): if not victim.is_npc(): ch.send("Not on PC's.\n") return if value < 0 or value > merc.MAX_LEVEL: ch.send("Level range is 0 to %d.\n" % merc.MAX_LEVEL) return ch.send("Level set to %d.\n" % value) victim.level = value return if "gold".startswith(arg2): victim.gold = value ch.send("Gold set to %d\n" % victim.gold) return if "silver".startswith(arg2): victim.silver = value ch.send("Silver set to %d\n" % victim.silver) return if "hp".startswith(arg2): if value < -10 or value > 30000: ch.send("Hp range is -10 to 30,000 hit points.\n") return victim.max_hit = value ch.send("Max Hitpoints set to %d\n" % value) if not victim.is_npc(): victim.perm_hit = value return if "mana".startswith(arg2): if value < 0 or value > 30000: ch.send("Mana range is 0 to 30,000 mana points.\n") return victim.max_mana = value ch.send("Max Mana set to %d\n" % value) if not victim.is_npc(): victim.perm_mana = value return if "move".startswith(arg2): if value < 0 or value > 30000: ch.send("Move range is 0 to 30,000 move points.\n") return victim.max_move = value ch.send("Max Move set to %d.\n" % value) if not victim.is_npc(): victim.perm_move = value return if "practice".startswith(arg2): if value < 0 or value > 250: ch.send("Practice range is 0 to 250 sessions.\n") return victim.practice = value ch.send("Victims practices set to %d.\n" % value) return if "train".startswith(arg2): if value < 0 or value > 50: ch.send("Training session range is 0 to 50 sessions.\n") return victim.train = value ch.send("Trains set to %d.\n" % value) return if "align".startswith(arg2): if value < -1000 or value > 1000: ch.send("Alignment range is -1000 to 1000.\n") return victim.alignment = value ch.send("Alignment set to %d.\n" % value) return if "thirst".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Thirst range is -1 to 100.\n") return victim.condition[merc.COND_THIRST] = value ch.send("Victims thirst set to %d.\n" % value) return if "drunk".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Drunk range is -1 to 100.\n") return victim.condition[merc.COND_DRUNK] = value ch.send("Victims Drunk set to %d.\n" % value) return if "full".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Full range is -1 to 100.\n") return ch.send("Full condition set to %d\n" % value) victim.condition[merc.COND_FULL] = value return if "hunger".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return if value < -1 or value > 100: ch.send("Full range is -1 to 100.\n") return ch.send("Hunger set to %d.\n" % value) victim.condition[merc.COND_HUNGER] = value return if "race".startswith(arg2): race = state_checks.prefix_lookup(const.race_table, arg3) if not race: ch.send("That is not a valid race.\n") return if not victim.is_npc() and race.name not in const.pc_race_table: ch.send("That is not a valid player race.\n") return ch.send("Race set to %s.\n" % race.name) victim.race = race return if "group".startswith(arg2): if not victim.is_npc(): ch.send("Only on NPCs.\n") return victim.group = value return # Generate usage message. ch.do_mset("")
def do_string(ch, argument): argument, type = game_utils.read_word(argument) argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) arg3 = argument.strip() if not type or not arg1 or not arg2 or not arg3: ch.send("Syntax:\n") ch.send(" string char <name> <field> <string>\n") ch.send(" fields: name short long desc title spec\n") ch.send(" string obj <name> <field> <string>\n") ch.send(" fields: name short long extended\n") return if "mobile".startswith(type) or "character".startswith(type): victim = ch.get_char_world(arg1) if not victim: ch.send("They aren't here.\n") return # clear zone for mobs victim.zone = None # string something if "name".startswith(arg2): if not victim.is_npc(): ch.send("Not on PC's.\n") return victim.name = arg3 return if "description".startswith(arg2): victim.description = arg3 return if "short".startswith(arg2): victim.short_descr = arg3 return if "long".startswith(arg2): victim.long_descr = arg3 + "\n" return if "title".startswith(arg2): if victim.is_npc(): ch.send("Not on NPC's.\n") return game_utils.set_title(victim, arg3) return if "spec".startswith(arg2): if not victim.is_npc(): ch.send("Not on PC's.\n") return spec = state_checks.prefix_lookup(special.spec_table, arg3) if not spec: ch.send("No such spec fun.\n") return victim.spec_fun = spec ch.send("spec_fun set.\n") return if "object".startswith(type): # string an obj obj = ch.get_item_world(arg1) if not obj: ch.send("Nothing like that in heaven or earth.\n") return if "name".startswith(arg2): obj.name = arg3 return if "short".startswith(arg2): obj.short_descr = arg3 return if "long".startswith(arg2): obj.description = arg3 return if "extended".startswith(arg2) or "ed".startswith(arg2): argument, arg3 = game_utils.read_word(argument) if argument is None: ch.send("Syntax: oset <object> ed <keyword> <string>\n") return argument += "\n" ed = world_classes.ExtraDescrData() ed.keyword = arg3 ed.description = argument obj.extra_descr.append(ed) return # echo bad use message ch.do_string("")
def cmd_mortal(ch, argument): if ch.is_npc(): return if not ch.is_vampire() and not ch.vampaff.is_set(merc.VAM_MORTAL): ch.huh() return if not ch.vampaff.is_set(merc.VAM_OBFUSCATE): ch.send("You are not trained in the Obfuscate discipline.\n") return if ch.is_vampire(): if ch.blood < 100: ch.send("You must be at full blood to use this power.\n") return # Have to make sure they have enough blood to change back blood = ch.blood ch.blood = 666 # Remove physical vampire attributes when you take mortal form if ch.vampaff.is_set(merc.VAM_DISGUISED): ch.cmd_mask("self") if ch.immune.is_set(merc.IMM_SHIELDED): ch.cmd_shield("") if ch.is_affected(merc.AFF_SHADOWPLANE): ch.cmd_shadowplane("") if ch.vampaff.is_set(merc.VAM_FANGS): ch.cmd_fangs("") if ch.vampaff.is_set(merc.VAM_CLAWS): ch.cmd_claws("") if ch.vampaff.is_set(merc.VAM_NIGHTSIGHT): ch.cmd_nightsight("") if ch.is_affected(merc.AFF_SHADOWSIGHT): ch.cmd_shadowsight("") if ch.act.is_set(merc.PLR_HOLYLIGHT): ch.cmd_truesight("") if ch.vampaff.is_set(merc.VAM_CHANGED): ch.cmd_change("human") if ch.polyaff.is_set(merc.POLY_SERPENT): ch.cmd_serpent("") ch.powers[merc.UNI_RAGE] = 0 ch.blood = blood ch.send("Colour returns to your skin and you warm up a little.\n") handler_game.act("Colour returns to $n's skin.", ch, None, None, merc.TO_ROOM) ch.ch_class = state_checks.prefix_lookup(const.class_table, "human") ch.vampaff.set_bit(merc.VAM_MORTAL) return ch.send("You skin pales and cools.\n") handler_game.act("$n's skin pales slightly.", ch, None, None, merc.TO_ROOM) ch.ch_class = state_checks.prefix_lookup(const.class_table, "vampire") ch.vampaff.rem_bit(merc.VAM_MORTAL)