def enhance_stat(self, level, victim, apply_bit, bonuses, affect_bit): if victim.itemaff.is_set(merc.ITEMA_REFLECT): # noinspection PyUnresolvedReferences self.send("You are unable to focus your spell.\n") return if state_checks.is_set(affect_bit, merc.AFF_WEBBED) and victim.is_affected( merc.AFF_WEBBED): state_checks.remove_bit(affect_bit, merc.AFF_WEBBED) elif state_checks.is_set( affect_bit, merc.AFF_WEBBED) and fight.is_safe(self, victim): state_checks.remove_bit(affect_bit, merc.AFF_WEBBED) if state_checks.is_set( affect_bit, merc.AFF_CHARM) and not victim.is_affected.is_set( merc.AFF_CHARM): if victim.level <= 50 and ( victim.is_npc() or not victim.immune.is_set(merc.IMM_CHARM)): if victim.master: victim.stop_follower() victim.add_follower(self) else: # noinspection PyUnresolvedReferences self.send("The spell failed.\n") return aff = handler_game.AffectData(type="reserved", duration=level, location=apply_bit, modifier=bonuses, bitvector=affect_bit) victim.affect_join(aff)
def cmd_open(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Open what?\n") return item = ch.get_item_here(arg) if item: # 'open object' if item.item_type not in [merc.ITEM_CONTAINER, merc.ITEM_BOOK]: ch.send("That's not a container.\n") return if not state_checks.is_set(item.value[1], merc.CONT_CLOSED): ch.send("It's already open.\n") return if not state_checks.is_set( item.value[1], merc.CONT_CLOSEABLE) and item.item_type != merc.ITEM_BOOK: ch.send("You can't do that.\n") return if state_checks.is_set(item.value[1], merc.CONT_LOCKED): ch.send("It's locked.\n") return state_checks.remove_bit(item.value[1], merc.CONT_CLOSED) ch.send("Ok.\n") handler_game.act("$n opens $p.", ch, item, None, merc.TO_ROOM) return door = handler_room.find_door(ch, arg) if door >= 0: # 'open door' pexit = ch.in_room.exit[door] if not pexit.exit_info.is_set(merc.EX_CLOSED): ch.send("It's already open.\n") return if pexit.exit_info.is_set(merc.EX_LOCKED): ch.send("It's locked.\n") return pexit.exit_info.rem_bit(merc.EX_CLOSED) handler_game.act("$n opens the $d.", ch, None, pexit.keyword, merc.TO_ROOM) ch.send("Ok.\n") # open the other side to_room = instance.rooms[pexit.to_room] pexit_rev = to_room.exit[merc.rev_dir[door]] if pexit.to_room else None if to_room and pexit_rev and pexit_rev.to_room == ch.in_room.instance_id: pexit_rev.exit_info.rem_bit(merc.EX_CLOSED) for rch_id in to_room.people[:]: rch = instance.characters[rch_id] handler_game.act("The $d opens.", rch, None, pexit_rev.keyword, merc.TO_CHAR)
def cmd_read(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("What do you wish to read?\n") return item = ch.get_item_here(arg) if not item: ch.send("You don't have that book.\n") return if item.item_type == merc.ITEM_PAGE: buf = ["{}.\n".format("Untitled page" if not item.victpoweruse else item.victpoweruse.capitalize())] if not item.chpoweruse: if not item.are_runes(): buf += "This page is blank.\n" elif ch.is_affected(merc.AFF_DETECT_MAGIC) and not item.quest.is_set(merc.QUEST_MASTER_RUNE) and not item.spectype.is_set(merc.ADV_STARTED): buf += living.Living.show_runes(item, False) else: buf += "This page is blank.\n" ch.send("".join(buf)) return buf += "--------------------------------------------------------------------------------\n" buf += item.chpoweruse + "\n" buf += "--------------------------------------------------------------------------------\n" if ch.is_affected(merc.AFF_DETECT_MAGIC) and not item.quest.is_set(merc.QUEST_MASTER_RUNE) and not item.spectype.is_set(merc.ADV_STARTED): buf += living.Living.show_runes(item, False) ch.send("".join(buf)) return if item.item_type != merc.ITEM_BOOK: ch.send("That's not a book.\n") return if state_checks.is_set(item.value[1], merc.CONT_CLOSED): if not item.victpoweruse: ch.send("The book is untitled.\n") else: ch.send("The book is titled '{}'.\n".format(item.victpoweruse)) return if item.value[2] == 0: buf = ["Index page.\n"] if item.value[3] <= 0: buf += "<No pages>\n" ch.send("".join(buf)) return for page in merc.irange(1, item.value[3]): buf += "Page {}:".format(page) buf += ch.show_page(item, page, True) else: buf = ["Page {}:".format(item.value[2])] buf += ch.show_page(item, item.value[2], False) ch.send("".join(buf))
def act_bit_name(act_flags): buf = "" if state_checks.is_set(act_flags, ACT_IS_NPC): buf += " npc" if act_flags & ACT_SENTINEL: buf += " sentinel" if act_flags & ACT_SCAVENGER: buf += " scavenger" if act_flags & ACT_AGGRESSIVE: buf += " aggressive" if act_flags & ACT_STAY_AREA: buf += " stay_area" if act_flags & ACT_WIMPY: buf += " wimpy" if act_flags & ACT_PET: buf += " pet" if act_flags & ACT_TRAIN: buf += " train" if act_flags & ACT_PRACTICE: buf += " practice" else: buf += " player" if act_flags & PLR_AUTOEXIT: buf += " autoexit" if act_flags & PLR_AUTOLOOT: buf += " autoloot" if act_flags & PLR_AUTOSAC: buf += " autosac" if act_flags & PLR_HOLYLIGHT: buf += " holy_light" return "none" if not buf else buf
def cmd_flee(ch, argument): victim = ch.fighting if not victim: if ch.position == merc.POS_FIGHTING: ch.position = merc.POS_STANDING ch.send("You aren't fighting anyone.\n") return if ch.is_affected(merc.AFF_WEBBED): ch.send("You are unable to move with all this sticky webbing on.\n") return if not ch.is_npc() and ch.powers[merc.UNI_RAGE] >= 0: if ch.is_vampire( ) and game_utils.number_percent() <= ch.powers[merc.UNI_RAGE]: ch.send("Your inner beast refuses to let you run!\n") ch.wait_state(merc.PULSE_VIOLENCE) return elif ch.is_werewolf( ) and game_utils.number_percent() <= ch.powers[merc.UNI_RAGE] * 0.3: ch.send("Your rage is too great!\n") ch.wait_state(merc.PULSE_VIOLENCE) return was_in = ch.in_room for attempt in range(6): door = handler_room.number_door() pexit = was_in.exit[door] if not pexit or not pexit.to_room or pexit.exit_info.is_set(merc.EX_CLOSED) or \ (ch.is_npc() and state_checks.is_set(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)): continue handler_ch.move_char(ch, door) now_in = ch.in_room if now_in == was_in: continue ch.in_environment = was_in.instance_id handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM) ch.in_environment = now_in.instance_id if not ch.is_npc(): ch.send("You flee from combat! Coward!\n") fight.stop_fighting(ch, True) return ch.send("You were unable to escape!\n")
def spl_remove_page(sn, level, ch, victim, target): handler_magic.target_name, arg = game_utils.read_word( handler_magic.target_name) if not arg: ch.send("Syntax is: cast 'remove page' <book>.\n") return book = ch.get_item_carry(arg) if not book: ch.send("You are not carrying that book.\n") return if book.item_type != merc.ITEM_BOOK: ch.send("That item isn't a book.\n") return if state_checks.is_set(book.value[1], merc.CONT_CLOSED): ch.send("First you need to open it!\n") return if book.value[2] == 0: ch.send("You cannot remove the index page!\n") return page = book.get_page(book.value[2]) if not page: ch.send("The page seems to have been torn out.\n") return book.get(page) ch.put(page) page.value[0] = 0 handler_game.act("You remove $p from $P.", ch, page, book, merc.TO_CHAR) handler_game.act("$n removes $p from $P.", ch, page, book, merc.TO_ROOM) count = 0 for page_id in book.inventory[:]: page = instance.items[page_id] count += 1 page.value[0] = count book.value[3] = count if book.value[2] > book.value[3]: book.value[2] = book.value[3]
def spl_insert_page(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 not arg1 or not arg2: ch.send("Syntax is: cast 'insert page' <page> <book>.\n") return page = ch.get_item_carry(arg1) if not page: ch.send("You are not carrying that page.\n") return if page.item_type != merc.ITEM_PAGE: ch.send("That item isn't a page.\n") return book = ch.get_item_carry(arg2) if not book: ch.send("You are not carrying that book.\n") return if book.item_type != merc.ITEM_BOOK: ch.send("That item isn't a book.\n") return if state_checks.is_set(book.value[1], merc.CONT_CLOSED): ch.send("First you need to open it!\n") return ch.get(page) book.put(page) book.value[3] += 1 book.value[2] = book.value[3] book.value[0] = book.value[3] page.specpower = book.value[3] + 1 handler_game.act("You insert $p into $P.", ch, page, book, merc.TO_CHAR) handler_game.act("$n inserts $p into $P.", ch, page, book, merc.TO_ROOM)
def cmd_turn(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: Turn <book> <forward/back>\n") return item = ch.get_item_here(arg1) if not item: ch.send("You don't have that book.\n") return if item.item_type != merc.ITEM_BOOK: ch.send("That's not a book.\n") return if state_checks.is_set(item.value[1], merc.CONT_CLOSED): ch.send("First you should open it.\n") return value = int(arg2) if arg2.isdigit() else 0 if game_utils.str_cmp(arg2, ["f", "forward"]): if item.value[2] >= item.value[3]: ch.send("But you are already at the end of the book.\n") return item.value[2] += 1 handler_game.act("You flip forward a page in $p.", ch, item, None, merc.TO_CHAR) handler_game.act("$n flips forward a page in $p.", ch, item, None, merc.TO_ROOM) elif game_utils.str_cmp(arg2, ["b", "backward"]): if item.value[2] <= 0: ch.send("But you are already at the beginning of the book.\n") return item.value[2] -= 1 handler_game.act("You flip backward a page in $p.", ch, item, None, merc.TO_CHAR) handler_game.act("$n flips backward a page in $p.", ch, item, None, merc.TO_ROOM) elif arg2.isdigit() and value in merc.irange(0, item.value[3]): if value == item.value[2]: handler_game.act("$p is already open at that page.", ch, item, None, merc.TO_CHAR) return if value < item.value[2]: handler_game.act("You flip backwards through $p.", ch, item, None, merc.TO_CHAR) handler_game.act("$n flips backwards through $p.", ch, item, None, merc.TO_ROOM) else: handler_game.act("You flip forwards through $p.", ch, item, None, merc.TO_CHAR) handler_game.act("$n flips forwards through $p.", ch, item, None, merc.TO_ROOM) item.value[2] = value else: ch.send("Do you wish to turn forward or backward a page?\n")
def cmd_chant(ch, argument): argument, arg = game_utils.read_word(argument) book = ch.get_eq("right_hand") if not book or book.item_type != merc.ITEM_BOOK: book = ch.get_eq("left_hand") if not book or book.item_type != merc.ITEM_BOOK: ch.send("First you must hold a spellbook.\n") return if state_checks.is_set(book.value[1], merc.CONT_CLOSED): ch.send("First you better open the book.\n") return if book.value[2] < 1: ch.send("There are no spells on the index page!\n") return page = book.get_page(book.value[2]) if not page: ch.send("The current page seems to have been torn out!\n") return spellcount = (page.value[1] * 10000) + (page.value[2] * 10) + page.value[3] handler_game.act("You chant the arcane words from $p.", ch, book, None, merc.TO_CHAR) handler_game.act("$n chants some arcane words from $p.", ch, book, None, merc.TO_ROOM) if page.quest.is_set(merc.QUEST_MASTER_RUNE): ch.spectype = 0 if page.spectype.is_set(merc.ADV_FAILED) or not page.spectype.is_set( merc.ADV_FINISHED) or page.points < 1: ch.send("The spell failed.\n") elif page.spectype.is_set(merc.ADV_DAMAGE): fight.adv_spell_damage(ch, book, page, argument) elif page.spectype.is_set(merc.ADV_AFFECT): fight.adv_spell_affect(ch, book, page, argument) elif page.spectype.is_set(merc.ADV_ACTION): fight.adv_spell_action(ch, book, page, argument) else: ch.send("The spell failed.\n") return spellno = 1 victim_target = False object_target = False global_target = False if spellcount == 10022: # FIRE + DESTRUCTION + TARGETING sn = "fireball" victim_target = True spellno = 2 elif spellcount == 640322: # LIFE + ENHANCEMENT + TARGETING sn = "heal" victim_target = True spellno = 2 elif spellcount == 1280044: # DEATH + SUMMONING + AREA sn = "guardian" spellno = 3 elif spellcount == 2565128: # MIND + INFORMATION + OBJECT sn = "identify" object_target = True global_target = True else: ch.send("Nothing happens.\n") return if not arg and (victim_target or object_target): ch.send("Please specify a target.\n") return if victim_target and sn in const.skill_table: if not global_target: victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return else: victim = ch.get_char_world(arg) if not victim: ch.not_here(arg) return if victim.itemaff.is_set(merc.ITEMA_REFLECT): ch.send("You are unable to focus your spell on them.\n") return spelltype = const.skill_table[sn].target level = ch.spl[spelltype] * 0.25 const.skill_table[sn].spell_fun(sn, level, ch, victim, merc.TARGET_CHAR) if spellno > 1: const.skill_table[sn].spell_fun(sn, level, ch, victim, merc.TARGET_CHAR) if spellno > 2: const.skill_table[sn].spell_fun(sn, level, ch, victim, merc.TARGET_CHAR) ch.wait_state(const.skill_table[sn].beats) elif object_target and sn in const.skill_table: if not global_target: item = ch.get_item_carry(arg) if not item: ch.send("You are not carrying that object.\n") return else: item = ch.get_item_world(arg) if not item: ch.send("You cannot find any object like that.\n") return spelltype = const.skill_table[sn].target level = ch.spl[spelltype] * 0.25 const.skill_table[sn].spell_fun(sn, level, ch, item, merc.TARGET_ITEM) if spellno > 1: const.skill_table[sn].spell_fun(sn, level, ch, item, merc.TARGET_ITEM) if spellno > 2: const.skill_table[sn].spell_fun(sn, level, ch, item, merc.TARGET_ITEM) ch.wait_state(const.skill_table[sn].beats) elif sn in const.skill_table: spelltype = const.skill_table[sn].target if spelltype == merc.TAR_OBJ_INV: ch.send("Nothing happens.\n") return level = ch.spl[spelltype] * 0.25 const.skill_table[sn].spell_fun(sn, level, ch, ch, merc.TARGET_CHAR) if spellno > 1: const.skill_table[sn].spell_fun(sn, level, ch, ch, merc.TARGET_CHAR) if spellno > 2: const.skill_table[sn].spell_fun(sn, level, ch, ch, merc.TARGET_CHAR) ch.wait_state(const.skill_table[sn].beats) else: ch.send("Nothing happens.\n")
def spl_copy(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("Syntax is: cast 'copy' <rune> <page>.\n") return rune = ch.get_item_carry(arg1) if not rune: ch.send("You are not carrying that rune.\n") return if rune.item_type != merc.ITEM_SYMBOL: ch.send("That item isn't a rune.\n") return page = ch.get_item_carry(arg2) if not page: ch.send("You are not carrying that page.\n") return if page.item_type != merc.ITEM_PAGE: ch.send("That item isn't a page.\n") return if page.value[1] > 0 and not state_checks.is_set( ch.powers[merc.MPOWER_RUNE1], page.value[1]): ch.send("You don't understand how that rune works.\n") return if page.value[2] > 0 and not state_checks.is_set( ch.powers[merc.MPOWER_RUNE2], page.value[2]): ch.send("You don't understand how that glyph works.\n") return if page.value[3] > 0 and not state_checks.is_set( ch.powers[merc.MPOWER_RUNE3], page.value[3]): ch.send("You don't understand how that sigil works.\n") return if rune.value[1] == merc.RUNE_MASTER: if page.quest.is_set(merc.QUEST_MASTER_RUNE): ch.send("There is already a master rune draw on this page.\n") return elif sum([page.value[0], page.value[1], page.value[2], page.value[3] ]) > 0: ch.send("There is already a spell on this page.\n") return else: handler_game.act("You copy $p rune onto $P.", ch, rune, page, merc.TO_CHAR) handler_game.act("$n copies $p rune onto $P.", ch, rune, page, merc.TO_ROOM) page.quest.set_bit(merc.QUEST_MASTER_RUNE) return elif page.quest.is_set(merc.QUEST_MASTER_RUNE): ch.send("There is already a master rune draw on this page.\n") return elif rune.value[1] > 0 and not state_checks.is_set(page.value[1], rune.value[1]): page.value[1] += rune.value[1] elif rune.value[1] > 0: ch.send("That rune has already been copied onto the page.\n") return elif rune.value[2] > 0 and not state_checks.is_set(page.value[2], rune.value[2]): page.value[2] += rune.value[2] elif rune.value[2] > 0: ch.send("That glyph has already been copied onto the page.\n") return elif rune.value[3] > 0 and not state_checks.is_set(page.value[3], rune.value[3]): page.value[3] += rune.value[3] elif rune.value[3] > 0: ch.send("That glyph has already been copied onto the page.\n") return handler_game.act("You copy $p onto $P.", ch, rune, page, merc.TO_CHAR) handler_game.act("$n copies $p onto $P.", ch, rune, page, merc.TO_ROOM)
def cmd_look(ch, argument): wizard = ch.wizard if not ch.desc and not wizard: return if ch.position < merc.POS_SLEEPING: ch.send("You can't see anything but stars!\n") return if ch.position == merc.POS_SLEEPING: ch.send("You can't see anything, you're sleeping!\n") return if ch.check_blind(): return if not ch.is_npc() and ch.in_room.room_flags.is_set(merc.ROOM_TOTAL_DARKNESS) and not ch.itemaff.is_set(merc.ITEMA_VISION) and \ not ch.is_affected(merc.AFF_SHADOWSIGHT) and not ch.is_immortal(): ch.send("It is pitch black ...\n") return if not ch.is_npc() and not ch.act.is_set(merc.PLR_HOLYLIGHT) and not ch.itemaff.is_set(merc.ITEMA_VISION) and \ not ch.vampaff.is_set(merc.VAM_NIGHTSIGHT) and not ch.is_affected(merc.AFF_SHADOWPLANE) and \ not (ch.in_room and ch.in_room.vnum == merc.ROOM_VNUM_IN_OBJECT and not ch.is_npc() and ch.chobj and ch.chobj.in_obj) and \ ch.in_room.is_dark(): ch.send("It is pitch black ...\n") handler_ch.show_char_to_char(ch.in_room.people, ch) return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or game_utils.str_cmp(arg1, "auto"): # 'look' or 'look auto' if ch.in_room and ch.in_room.vnum == merc.ROOM_VNUM_IN_OBJECT and not ch.is_npc( ) and ch.chobj and ch.chobj.in_obj: handler_game.act("$p", ch, ch.chobj.in_obj, None, merc.TO_CHAR) elif ch.is_affected(merc.AFF_SHADOWPLANE): ch.send("The shadow plane\n") else: ch.send(ch.in_room.name + "\n") if not ch.is_npc() and ch.act.is_set(merc.PLR_AUTOEXIT): ch.cmd_exits("auto") if ch.in_room and ch.in_room.vnum == merc.ROOM_VNUM_IN_OBJECT and not ch.is_npc( ) and ch.chobj and ch.chobj.in_obj: handler_game.act("You are inside $p.", ch, ch.chobj.in_obj, None, merc.TO_CHAR) handler_ch.show_list_to_char(ch.chobj.in_obj.items, ch, False, False) elif (not arg1 or game_utils.str_cmp(arg1, "auto")) and ch.is_affected( merc.AFF_SHADOWPLANE): ch.send("You are standing in complete darkness.\n") elif (not ch.is_npc() and not ch.act.is_set(merc.PLR_BRIEF)) and ( not arg1 or game_utils.str_cmp(arg1, "auto")): ch.send(ch.in_room.description + "\n") if ch.in_room.blood > 0: if ch.in_room.blood == 1000: buf = "#RYou notice that the room is completely drenched in blood.#n\n" elif ch.in_room.blood > 750: buf = "#RYou notice that there is a very large amount of blood around the room.#n\n" elif ch.in_room.blood > 500: buf = "#RYou notice that there is a large quantity of blood around the room.#n\n" elif ch.in_room.blood > 250: buf = "#RYou notice a fair amount of blood on the floor.#n\n" elif ch.in_room.blood > 100: buf = "#RYou notice several blood stains on the floor.#n\n" elif ch.in_room.blood > 50: buf = "#RYou notice a few blood stains on the floor.#n\n" elif ch.in_room.blood > 25: buf = "#RYou notice a couple of blood stains on the floor.#n\n" elif ch.in_room.blood > 0: buf = "#RYou notice a few drops of blood on the floor.#n\n" else: buf = "#RYou notice nothing special in the room.#n\n" ch.send(buf) handler_ch.show_list_to_char(ch.in_room.items, ch, False, False) handler_ch.show_char_to_char(ch.in_room.people, ch) return if game_utils.str_cmp(arg1, ["i", "in"]): # 'look in' if not arg2: ch.send("Look in what?\n") return item = ch.get_item_here(arg2) if not item: ch.send("You do not see that here.\n") return if item.item_type == merc.ITEM_PORTAL: proomindex = instance.rooms[item.value[0]] location = ch.in_room if not proomindex: ch.send("It doesn't seem to lead anywhere.\n") return if item.value[2] == 1 or item.value[2] == 3: ch.send("It seems to be closed.\n") return ch.in_room.get(ch) proomindex.put(ch) for portal_id in ch.in_room.items: portal = instance.items[portal_id] if item.value[0] == portal.value[3] and item.value[ 3] == portal.value[0]: if ch.is_affected(merc.AFF_SHADOWPLANE ) and not portal.flags.shadowplane: ch.affected_by.rem_bit(merc.AFF_SHADOWPLANE) ch.cmd_look("auto") ch.affected_by.set_bit(merc.AFF_SHADOWPLANE) break elif not ch.is_affected( merc.AFF_SHADOWPLANE) and portal.flags.shadowplane: ch.affected_by.set_bit(merc.AFF_SHADOWPLANE) ch.cmd_look("auto") ch.affected_by.rem_bit(merc.AFF_SHADOWPLANE) break else: ch.cmd_look("auto") break ch.in_room.get(ch) location.put(ch) elif item.item_type == merc.ITEM_DRINK_CON: if item.value[1] <= 0: ch.send("It is empty.\n") return if item.value[1] < item.value[0] // 5: ch.send("There is a little {} liquid left in it.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0] // 4: ch.send("It contains a small about of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0] // 3: ch.send("It's about a third full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0] // 2: ch.send("It's about half full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] < item.value[0]: ch.send("It is almost full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.value[1] == item.value[0]: ch.send("It's completely full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) else: ch.send("Somehow it is MORE than full of {} liquid.\n".format( const.liq_table[item.value[2]].color)) elif item.item_type in [ merc.ITEM_CONTAINER, merc.ITEM_CORPSE_NPC, merc.ITEM_CORPSE_PC ]: if state_checks.is_set(item.value[1], merc.CONT_CLOSED): ch.send("It is closed.\n") return handler_game.act("$p contains:", ch, item, None, merc.TO_CHAR) handler_ch.show_list_to_char(item.inventory, ch, True, True) else: ch.send("That is not a container.\n") return victim = ch.get_char_room(arg1) if victim: handler_ch.show_char_to_char_1(victim, ch) return for vch in list(instance.characters.values()): if not vch.in_room: continue if vch.in_room == ch.in_room: if not vch.is_npc() and game_utils.str_cmp(arg1, vch.morph): handler_ch.show_char_to_char_1(vch, ch) return continue if not ch.is_npc() and ch.chobj and ch.chobj.in_obj: item = ch.get_item_in_item(arg1) if item: ch.send(item.description + "\n") return item_list = list(ch.items) item_list.extend(ch.in_room.items) for item_id in item_list: item = instance.items[item_id] if not ch.is_npc() and ch.chobj and item.chobj and item.chobj == ch: continue if ch.can_see_item(item): pdesc = game_utils.get_extra_descr(arg1, item.extra_descr) if pdesc: ch.send(pdesc) return if game_utils.is_name(arg1, item.name): ch.send(item.description + "\n") return pdesc = game_utils.get_extra_descr(arg1, ch.in_room.extra_descr) if pdesc: ch.send(pdesc) return dir_list = [(["n", "north"], merc.DIR_NORTH), (["e", "east"], merc.DIR_EAST), (["s", "south"], merc.DIR_SOUTH), (["w", "west"], merc.DIR_WEST), (["u", "up"], merc.DIR_UP), (["d", "down"], merc.DIR_DOWN)] for (aa, bb) in dir_list: if game_utils.str_cmp(arg1, aa): door = bb break else: ch.send("You do not see that here.\n") return # 'look direction' pexit = ch.in_room.exit[door] if not pexit: ch.send("Nothing special there.\n") return if pexit.keyword and pexit.keyword[0] != " ": if pexit.exit_info.is_set(merc.EX_CLOSED): handler_game.act("The $d is closed.", ch, None, pexit.keyword, merc.TO_CHAR) elif pexit.exit_info.is_set(merc.EX_ISDOOR): handler_game.act("The $d is open.", ch, None, pexit.keyword, merc.TO_CHAR) pexit = ch.in_room.exit[door] if not pexit: return proomindex = instance.rooms[pexit.to_room] if not proomindex: return location = ch.in_room ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") ch.in_room.get(ch) location.put(ch) else: pexit = ch.in_room.exit[door] if not pexit: return proomindex = instance.rooms[pexit.to_room] if not proomindex: return location = ch.in_room ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") ch.in_room.get(ch) location.put(ch) else: pexit = ch.in_room.exit[door] if not pexit: return proomindex = instance.rooms[pexit.to_room] if not proomindex: return location = ch.in_room ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") ch.in_room.get(ch) location.put(ch)
def cmd_finger(ch, argument): if not argument: ch.send("Usage: finger <victim>\n") return if not nanny.check_parse_name(argument): ch.send("Thats an illegal name.\n") return ch_dummy = nanny.CharDummy() ch_dummy.stub = handler_pc.Pc.load_stub(argument, silent=True) if not ch_dummy.stub: ch.send("That player doesn't exist.\n") del ch_dummy return buf = [ "--------------------------------------------------------------------------------\n" ] buf += "{}{}.\n".format(ch_dummy.stub["name"], ch_dummy.stub["title"]) buf += "--------------------------------------------------------------------------------\n" if ch.is_immortal(): buf += "Last connected from {} at {}.\n".format( ch_dummy.stub["last_host"], sys_utils.systimestamp(ch_dummy.stub["last_time"])) else: buf += "Last connected from ***.***.***.*** at {}.\n".format( sys_utils.systimestamp(ch_dummy.stub["last_time"])) buf += "--------------------------------------------------------------------------------\n" buf += "Sex: {}. ".format( tables.sex_table[ch_dummy.stub["sex"]].capitalize()) buf += ch.other_age(is_self=False) if ch_dummy.stub["level"] >= merc.LEVEL_IMMORTAL: level_list = [(merc.LEVEL_HIGHJUDGE, " High Judge"), (merc.LEVEL_JUDGE, " Judge"), (merc.LEVEL_ENFORCER, "n Enforcer"), (merc.LEVEL_QUESTMAKER, " Quest Maker"), (merc.LEVEL_BUILDER, " Builder")] for (aa, bb) in level_list: if ch_dummy.stub["level"] == aa: buf += "They are a{}, ".format(bb) break else: buf += "They are an Implementor, " else: level_list = [(1, "n Avatar"), (5, "n Immortal"), (10, " Godling"), (15, " Demigod"), (20, " Lesser God"), (25, " Greater God")] for (aa, bb) in level_list: if ch_dummy.stub["race"] < aa: buf += "They are a{}, ".format(bb) break else: buf += "They are a Supreme God, " played = ch_dummy.stub["played"] played = (2 * (played // 7200)) if played > 0 else 0 buf += "and have been playing for {} hours.\n".format(played) if ch_dummy.stub["marriage"]: buf += "They are {} to {}.\n".format( "married" if state_checks.is_set( ch_dummy.stub["extra"], merc.EXTRA_MARRIED) else "engaged", ch_dummy.stub["marriage"]) buf += "Player kills: {}, Player Deaths: {}.\n".format( ch_dummy.stub["pkills"], ch_dummy.stub["pdeaths"]) buf += "Mob kills: {}, Mob Deaths: {}.\n".format(ch_dummy.stub["mkills"], ch_dummy.stub["mdeaths"]) buf += "--------------------------------------------------------------------------------\n" if ch_dummy.stub["email"]: buf += "Email: {}\n".format(ch_dummy.stub["email"]) buf += "--------------------------------------------------------------------------------\n" ch.send("".join(buf)) del ch_dummy
def cmd_get(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if ch.is_affected(merc.AFF_ETHEREAL): ch.send("You cannot pick things up while ethereal.\n") return # Get type. if not arg1: ch.send("Get what?\n") return if not arg2: if not game_utils.str_cmp(arg1, "all") and not game_utils.str_prefix( "all.", arg1): # 'get obj' item = ch.get_item_list(arg1, ch.in_room.items) if not item: handler_game.act("I see no $T here.", ch, None, arg1, merc.TO_CHAR) return handler_item.get_item(ch, item, None) else: # 'get all' or 'get all.obj' found = False for item_id in ch.in_room.items: item = instance.items[item_id] if (len(arg1) == 3 or game_utils.is_name( arg1[4:], item.name)) and ch.can_see_item(item): found = True handler_item.get_item(ch, item, None) if not found: if len(arg1) == 3: ch.send("I see nothing here.\n") else: handler_game.act("I see no $T here.", ch, None, arg1[4:], merc.TO_CHAR) else: # 'get ... container' if game_utils.str_cmp(arg2, "all") or game_utils.str_prefix( "all.", arg2): ch.send("You can't do that.\n") return container = ch.get_item_here(arg2) if not container: handler_game.act("I see no $T here.", ch, None, arg2, merc.TO_CHAR) return itype = container.item_type if itype == merc.ITEM_CORPSE_PC: if ch.is_npc(): ch.send("You can't do that.\n") return elif itype not in [merc.ITEM_CONTAINER, merc.ITEM_CORPSE_NPC]: ch.send("That's not a container.\n") return if state_checks.is_set(container.value[1], merc.CONT_CLOSED): handler_game.act("The $d is closed.", ch, None, container.name, merc.TO_CHAR) return if not game_utils.str_cmp(arg1, "all") and not game_utils.str_prefix( "all.", arg1): # 'get obj container' item = ch.get_item_list(arg1, container.inventory) if not item: handler_game.act("I see nothing like that in the $T.", ch, None, arg2, merc.TO_CHAR) return handler_item.get_item(ch, item, container) else: # 'get all container' or 'get all.obj container' found = False for item_id in container.inventory[:]: item = instance.items[item_id] if (len(arg1) == 3 or game_utils.is_name( arg1[4:], item.name)) and ch.can_see_item(item): found = True handler_item.get_item(ch, item, container) if not found: if len(arg1) == 3: handler_game.act("I see nothing in the $T.", ch, None, arg2, merc.TO_CHAR) else: handler_game.act("I see nothing like that in the $T.", ch, None, arg2, merc.TO_CHAR) ch.save(force=True)
def cmd_pick(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Pick what?\n") return ch.wait_state(const.skill_table["pick lock"].beats) # look for guards for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if gch.is_npc() and gch.is_awake() and ch.level + 5 < gch.level: handler_game.act("$N is standing too close to the lock.", ch, None, gch, merc.TO_CHAR) return if not ch.is_npc( ) and game_utils.number_percent() > ch.learned["pick lock"]: ch.send("You failed.\n") return item = ch.get_item_here(arg) if item: # 'pick object' if item.item_type != merc.ITEM_CONTAINER: ch.send("That's not a container.\n") return if not state_checks.is_set(item.value[1], merc.CONT_CLOSED): ch.send("It's not closed.\n") return if item.value < 0: ch.send("It can't be unlocked.\n") return if not state_checks.is_set(item.value[1], merc.CONT_LOCKED): ch.send("It's already unlocked.\n") return if state_checks.is_set(item.value[1], merc.CONT_PICKPROOF): ch.send("You failed.\n") return state_checks.remove_bit(item.value[1], merc.CONT_LOCKED) ch.send("*Click*\n") handler_game.act("$n picks $p.", ch, item, None, merc.TO_ROOM) return door = handler_room.find_door(ch, arg) if door >= 0: # 'pick door' pexit = ch.in_room.exit[door] if not pexit.exit_info.is_set(merc.EX_CLOSED): ch.send("It's not closed.\n") return if pexit.key < 0: ch.send("It can't be picked.\n") return if not pexit.exit_info.is_set(merc.EX_LOCKED): ch.send("It's already unlocked.\n") return if pexit.exit_info.is_set(merc.EX_PICKPROOF): ch.send("You failed.\n") return pexit.exit_info.rem_bit(merc.EX_LOCKED) ch.send("*Click*\n") handler_game.act("$n picks the $d.", ch, None, pexit.keyword, merc.TO_ROOM) # pick the other side to_room = instance.rooms[pexit.to_room] if to_room and to_room.exit[merc.rev_dir[door]] != 0 and to_room.exit[ merc.rev_dir[door]].to_room == ch.in_room: to_room.exit[merc.rev_dir[door]].exit_info.rem_bit(merc.EX_LOCKED)
def room_text(ch, argument): for rt in ch.in_room.roomtext: if game_utils.str_cmp(argument, rt.input) or game_utils.is_in(argument, rt.input) or game_utils.all_in(argument, rt.input): if rt.name and not game_utils.str_cmp(rt.name, ["all", "|all*"]): if not game_utils.is_in(ch.name, rt.name): continue mobfound = True if rt.mob != 0: mobfound = False for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if not vch.is_npc(): continue if vch.vnum == rt.mob: mobfound = True break if not mobfound: continue hop = False rtype = rt.type % merc.RT_RETURN if rtype == merc.RT_SAY: pass elif rtype == merc.RT_LIGHTS: ch.cmd_changelight("") elif rtype == merc.RT_LIGHT: ch.in_room.room_flags.rem_bit(merc.ROOM_DARK) elif rtype == merc.RT_DARK: ch.in_room.room_flags.set_bit(merc.ROOM_DARK) elif rtype == merc.RT_OBJECT: obj_index = instance.item_templates[rt.power] if not obj_index: return item = object_creator.create_item(obj_index, ch.level) if state_checks.is_set(rt.type, merc.RT_TIMER): item.timer = 1 if item.flags.take: ch.put(item) else: ch.in_room.put(item) if game_utils.str_cmp(rt.choutput, "copy"): handler_game.act(rt.output, ch, item, None, merc.TO_CHAR) else: handler_game.act(rt.choutput, ch, item, None, merc.TO_CHAR) if not state_checks.is_set(rt.type, merc.RT_PERSONAL): handler_game.act(rt.output, ch, item, None, merc.TO_ROOM) hop = True elif rtype == merc.RT_MOBILE: mob_index = instance.npc_templates[rt.power] if not mob_index: return mob = object_creator.create_mobile(mob_index) ch.in_room.put(mob) if game_utils.str_cmp(rt.choutput, "copy"): handler_game.act(rt.output, ch, None, mob, merc.TO_CHAR) else: handler_game.act(rt.choutput, ch, None, mob, merc.TO_CHAR) if not state_checks.is_set(rt.type, merc.RT_PERSONAL): handler_game.act(rt.output, ch, None, mob, merc.TO_ROOM) hop = True elif rtype == merc.RT_SPELL: const.skill_table[rt.power].spell_fun(rt.power, game_utils.number_range(20, 30), ch, ch, merc.TARGET_CHAR) elif rtype == merc.RT_PORTAL: if merc.OBJ_VNUM_PORTAL not in instance.item_templates: return item = object_creator.create_item(instance.item_templates[merc.OBJ_VNUM_PORTAL], 0) item.timer = 1 item.value[0] = rt.power item.value[1] = 1 ch.in_room.put(item) elif rtype == merc.RT_TELEPORT: room = instance.rooms[rt.power] if not room: return if game_utils.str_cmp(rt.choutput, "copy"): handler_game.act(rt.output, ch, None, None, merc.TO_CHAR) else: handler_game.act(rt.choutput, ch, None, None, merc.TO_CHAR) if not state_checks.is_set(rt.type, merc.RT_PERSONAL): handler_game.act(rt.output, ch, None, None, merc.TO_ROOM) ch.in_room.get(ch) room.put(ch) handler_game.act("$n appears in the room.", ch, None, None, merc.TO_ROOM) ch.cmd_look("auto") hop = True elif rtype == merc.RT_ACTION: arg = argument argument, arg1 = game_utils.read_word(arg) argument, arg2 = game_utils.read_word(arg) mob = ch.get_char_room(arg2) if not mob: return mob.interpret(rt.output) elif rtype == merc.RT_OPEN_LIFT: open_lift(ch) elif rtype == merc.RT_CLOSE_LIFT: close_lift(ch) elif rtype == merc.RT_MOVE_LIFT: move_lift(ch, rt.power) if hop and state_checks.is_set(rt.type, merc.RT_RETURN): return elif hop: continue if game_utils.str_cmp(rt.choutput, "copy") and not state_checks.is_set(rt.type, merc.RT_ACTION): handler_game.act(rt.output, ch, None, None, merc.TO_CHAR) elif not state_checks.is_set(rt.type, merc.RT_ACTION): handler_game.act(rt.choutput, ch, None, None, merc.TO_CHAR) if not state_checks.is_set(rt.type, merc.RT_PERSONAL) and not state_checks.is_set(rt.type, merc.RT_ACTION): handler_game.act(rt.output, ch, None, None, merc.TO_ROOM) if state_checks.is_set(rt.type, merc.RT_RETURN): return
def cmd_put(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Put what in what?\n") return if game_utils.str_cmp(arg2, "all") or game_utils.str_prefix("all.", arg2): ch.send("You can't do that.\n") return container = ch.get_item_here(arg2) if not container: handler_game.act("I see no $T here.", ch, None, arg2, merc.TO_CHAR) return if container.item_type != merc.ITEM_CONTAINER: ch.send("That's not a container.\n") return if state_checks.is_set(container.value[1], merc.CONT_CLOSED): handler_game.act("The $d is closed.", ch, None, container.name, merc.TO_CHAR) return if not game_utils.str_cmp(arg1, "all") and not game_utils.str_prefix( "all.", arg1): # 'put obj container' item = ch.get_item_carry(arg1) if not item: ch.send("You do not have that item.\n") return if item == container: ch.send("You can't fold it into itself.\n") return if item.flags.artifact: ch.send("You cannot put artifacts in a container.\n") return if not ch.can_drop_item(item): ch.send("You can't let go of it.\n") return if item.get_weight() + container.get_weight() > container.value[0]: ch.send("It won't fit.\n") return for item2_id in container.inventory[:]: item2 = instance.items[item2_id] if item2.chobj and item != item2: handler_game.act("A hand reaches inside $P and drops $p.", item2.chobj, item, container, merc.TO_CHAR) ch.get(item) container.put(item) handler_game.act("$n puts $p in $P.", ch, item, container, merc.TO_ROOM) handler_game.act("You put $p in $P.", ch, item, container, merc.TO_CHAR) else: objroom = instance.rooms[merc.ROOM_VNUM_IN_OBJECT] # 'put all container' or 'put all.obj container' for item in ch.inventory[:]: if (len(arg1) == 3 or game_utils.is_name(arg1[4:], item.name)) and ch.can_see_item(item) and not item.equipped_to and \ item != container and not item.flags.artifact and ch.can_drop_item(item) and \ item.get_weight() + container.true_weight() <= container.value[0]: for item2 in container.inventory[:]: if item2.chobj and item2.chobj.in_room: if objroom != instance.rooms[item2.chobj.in_room.vnum]: item2.chobj.in_room.get(item2.chobj) objroom.put(item2.chobj) item2.chobj.cmd_look("auto") if item != item2: handler_game.act( "A hand reaches inside $P and drops $p.", item2.chobj, item, container, merc.TO_CHAR) ch.get(item) container.put(item) handler_game.act("$n puts $p in $P.", ch, item, container, merc.TO_ROOM) handler_game.act("You put $p in $P.", ch, item, container, merc.TO_CHAR) ch.save(force=True)
def spl_major_creation(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: ch.send("Item can be one of: Rune, Glyph, Sigil, Book, Page or Pen.\n") return itemname = "" vn = 0 itempower = 0 # The Rune is the foundation/source of the spell. # The Glyphs form the focus/purpose of the spell. # The Sigils form the affects of the spell. if game_utils.str_cmp(arg1, "rune"): if not arg2: ch.send("You know of no such Rune.\n") return itemtype = merc.ITEM_SYMBOL vn = 1 itemkind = "rune" rune_list = [("fire", merc.RUNE_FIRE), ("air", merc.RUNE_AIR), ("earth", merc.RUNE_EARTH), ("water", merc.RUNE_WATER), ("dark", merc.RUNE_DARK), ("light", merc.RUNE_LIGHT), ("life", merc.RUNE_LIFE), ("death", merc.RUNE_DEATH), ("mind", merc.RUNE_MIND), ("spirit", merc.RUNE_SPIRIT), ("mastery", merc.RUNE_MASTER)] for (aa, bb) in rune_list: if game_utils.str_cmp(arg2, aa): itemname = aa itempower = bb break else: ch.send("You know of no such Rune.\n") return if not state_checks.is_set(ch.powers[vn], itempower): ch.send("You know of no such Rune.\n") return elif game_utils.str_cmp(arg1, "glyph"): if not arg2: ch.send("You know of no such Glyph.\n") return itemtype = merc.ITEM_SYMBOL vn = 2 itemkind = "glyph" glyph_list = [("creation", merc.GLYPH_CREATION), ("destruction", merc.GLYPH_DESTRUCTION), ("summoning", merc.GLYPH_SUMMONING), ("transformation", merc.GLYPH_TRANSFORMATION), ("transportation", merc.GLYPH_TRANSPORTATION), ("enhancement", merc.GLYPH_ENHANCEMENT), ("reduction", merc.GLYPH_DESTRUCTION), ("control", merc.GLYPH_CONTROL), ("protection", merc.GLYPH_PROTECTION), ("information", merc.GLYPH_INFORMATION)] for (aa, bb) in glyph_list: if game_utils.str_cmp(arg2, aa): itemname = aa itempower = bb break else: ch.send("You know of no such Glyph.\n") return if not state_checks.is_set(ch.powers[vn], itempower): ch.send("You know of no such Glyph.\n") return elif game_utils.str_cmp(arg1, "sigil"): if not arg2: ch.send("You know of no such Sigil.\n") return itemtype = merc.ITEM_SYMBOL vn = 3 itemkind = "sigil" sigil_list = [("self", merc.SIGIL_SELF), ("targeting", merc.SIGIL_TARGETING), ("area", merc.SIGIL_AREA), ("object", merc.SIGIL_OBJECT)] for (aa, bb) in sigil_list: if game_utils.str_cmp(arg2, aa): itemname = aa itempower = bb break else: ch.send("You know of no such Sigil.\n") return if not state_checks.is_set(ch.powers[vn], itempower): ch.send("You know of no such Sigil.\n") return elif game_utils.str_cmp(arg1, "book"): itemtype = merc.ITEM_BOOK itemkind = "book" elif game_utils.str_cmp(arg1, "page"): itemtype = merc.ITEM_PAGE itemkind = "page" elif game_utils.str_cmp(arg1, "pen"): itemtype = merc.ITEM_TOOL itemkind = "pen" else: ch.send("Item can be one of: Rune, Glyph, Sigil, Book, Page or Pen.\n") return item = object_creator.create_item( instance.item_templates[merc.OBJ_VNUM_PROTOPLASM], 0) item.item_type = itemtype if itemtype == merc.ITEM_SYMBOL: buf = "{} {}".format(itemkind, itemname) item.value[vn] = itempower else: buf = "{}".format(itemkind) if itemtype == merc.ITEM_TOOL: item.value[0] = merc.TOOL_PEN item.weight = 1 item.flags.take = True item.hold = True elif itemtype == merc.ITEM_BOOK: item.weight = 50 item.flags.take = True item.hold = True item.name = buf if itemtype == merc.ITEM_SYMBOL: item.short_descr = "a {} of {}".format(itemkind, itemname) else: item.short_descr = "a {}".format(itemkind) item.description = "A {} lies here.".format(itemkind) item.questmaker = ch.name ch.put(item) handler_game.act("$p suddenly appears in your hands.", ch, item, None, merc.TO_CHAR) handler_game.act("$p suddenly appears in $n's hands.", ch, item, None, merc.TO_ROOM)
def cmd_lock(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Lock what?\n") return item = ch.get_item_here(arg) if item: # 'lock object' if item.item_type != merc.ITEM_CONTAINER: ch.send("That's not a container.\n") return if not state_checks.is_set(item.value[1], merc.CONT_CLOSED): ch.send("It's not closed.\n") return if item.value[2] < 0: ch.send("It can't be locked.\n") return if not ch.valid_key(item.value[2]): ch.send("You lack the key.\n") return if state_checks.is_set(item.value[1], merc.CONT_LOCKED): ch.send("It's already locked.\n") return state_checks.set_bit(item.value[1], merc.CONT_LOCKED) ch.send("*Click*\n") handler_game.act("$n locks $p.", ch, item, None, merc.TO_ROOM) return door = handler_room.find_door(ch, arg) if door >= 0: # 'lock door' pexit = ch.in_room.exit[door] if not pexit.exit_info.is_set(merc.EX_CLOSED): ch.send("It's not closed.\n") return if pexit.key < 0: ch.send("It can't be locked.\n") return if not ch.valid_key(pexit.key): ch.send("You lack the key.\n") return if pexit.exit_info.is_set(merc.EX_LOCKED): ch.send("It's already locked.\n") return pexit.exit_info.set_bit(merc.EX_LOCKED) ch.send("*Click*\n") handler_game.act("$n locks the $d.", ch, None, pexit.keyword, merc.TO_ROOM) # lock the other side to_room = instance.rooms[pexit.to_room] if to_room and to_room.exit[merc.rev_dir[door]] != 0 and to_room.exit[merc.rev_dir[door]].to_room == ch.in_room: to_room.exit[merc.rev_dir[door]].exit_info.set_bit(merc.EX_LOCKED)
def cmd_write(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) arg3 = argument if ch.is_npc(): return if not arg1 or not arg2 or not arg3: ch.send("Syntax: Write <page> <title/line> <text>.\n") return item = ch.get_eq("left_hand") if not item or (item.item_type != merc.ITEM_TOOL or not state_checks.is_set(item.value[0], merc.TOOL_PEN)): item = ch.get_eq("right_hand") if not item or (item.item_type != merc.ITEM_TOOL or not state_checks.is_set(item.value[0], merc.TOOL_PEN)): ch.send("You are not holding a pen.\n") return item = ch.get_item_carry(arg1) if not item: ch.send("You are not carrying that item.\n") return if item.item_type not in [merc.ITEM_PAGE, merc.ITEM_BOOK]: ch.send("You cannot write on that.\n") return if game_utils.str_cmp(arg2, "title"): item.victpoweruse = arg3 ch.send("Ok.\n") handler_game.act("$n writes something on $p.", ch, item, None, merc.TO_ROOM) return if not game_utils.str_cmp(arg2, "line"): ch.send("You can write a TITLE or a LINE.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("You can only write a title on the book.\n") return if not item.chpoweruse: return buf = item.chpoweruse if not buf: item.chpoweruse = arg3.capitalize() ch.send("Ok.\n") handler_game.act("$n writes something on $p.", ch, item, None, merc.TO_ROOM) if not ch.is_mage() and not ch.is_immortal() and not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_FAILED) elif game_utils.str_cmp(arg3, "start.damage.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) item.spectype.set_bit(merc.ADV_DAMAGE) elif game_utils.str_cmp(arg3, "start.affect.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) item.spectype.set_bit(merc.ADV_AFFECT) elif game_utils.str_cmp(arg3, "start.action.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) item.spectype.set_bit(merc.ADV_ACTION) elif game_utils.str_cmp(arg3, "start.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) elif not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_FAILED) return if item.chpoweruse and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return item.chpoweruse = buf + "\n" + arg3 argument, arg1 = game_utils.read_word(argument) arg2 = argument if not ch.is_mage() and not ch.is_immortal() and not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_FAILED) elif game_utils.str_cmp(arg1, "start.damage.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) item.spectype.set_bit(merc.ADV_DAMAGE) elif game_utils.str_cmp(arg1, "start.affect.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) item.spectype.set_bit(merc.ADV_AFFECT) elif game_utils.str_cmp(arg1, "start.action.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) item.spectype.set_bit(merc.ADV_ACTION) elif game_utils.str_cmp(arg1, "start.spell") and item.spectype.empty(): item.spectype.set_bit(merc.ADV_STARTED) elif game_utils.str_cmp(arg1, "end.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_FINISHED) item.toughness = ch.powers[merc.MPOWER_RUNE0] item.points += 1 elif game_utils.str_cmp(arg1, "damage.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_DAMAGE) and \ not item.spectype.is_set(merc.ADV_AFFECT) and not item.spectype.is_set(merc.ADV_ACTION) and not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_DAMAGE) elif game_utils.str_cmp(arg1, "affect.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_DAMAGE) and \ not item.spectype.is_set(merc.ADV_AFFECT) and not item.spectype.is_set(merc.ADV_ACTION) and not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_AFFECT) elif game_utils.str_cmp(arg1, "action.spell") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_DAMAGE) and \ not item.spectype.is_set(merc.ADV_AFFECT) and not item.spectype.is_set(merc.ADV_ACTION) and not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_AFFECT) elif game_utils.str_cmp(arg1, "area.affect") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_AREA_AFFECT) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_AREA_AFFECT) item.points += 100 elif game_utils.str_cmp(arg1, "victim.target") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_VICTIM_TARGET) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_VICTIM_TARGET) item.points += 5 elif game_utils.str_cmp(arg1, "object.target") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_OBJECT_TARGET) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_OBJECT_TARGET) item.points += 5 elif game_utils.str_cmp(arg1, "global.target") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_GLOBAL_TARGET) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_GLOBAL_TARGET) item.points += 50 elif game_utils.str_cmp(arg1, "next.page") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_NEXT_PAGE) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_NEXT_PAGE) item.points += 5 elif game_utils.str_cmp(arg1, "parameter:") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_PARAMETER) and \ not item.spectype.is_set(merc.ADV_FINISHED): if not arg2: item.spectype.set_bit(merc.ADV_FAILED) else: item.spectype.set_bit(merc.ADV_PARAMETER) item.chpoweron = arg2 elif game_utils.str_cmp(arg1, "spell.first") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_SPELL_FIRST) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_SPELL_FIRST) elif game_utils.str_cmp(arg1, "not.caster") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_NOT_CASTER) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_NOT_CASTER) elif game_utils.str_cmp(arg1, "no.players") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_NO_PLAYERS) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_NO_PLAYERS) elif game_utils.str_cmp(arg1, "second.victim") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_SECOND_VICTIM) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_SECOND_VICTIM) item.points += 5 elif game_utils.str_cmp(arg1, "second.object") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_SECOND_OBJECT) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_SECOND_OBJECT) item.points += 5 elif game_utils.str_cmp(arg1, "reversed") and item.spectype.is_set(merc.ADV_STARTED) and not item.spectype.is_set(merc.ADV_REVERSED) and \ not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_REVERSED) elif game_utils.str_cmp(arg1, "min.damage:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_DAMAGE) and \ not item.spectype.is_set(merc.ADV_FINISHED): if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(0, 500): item.spectype.set_bit(merc.ADV_FAILED) else: item.value[1] = int(arg2) item.points += int(arg2) * 0.5 elif game_utils.str_cmp(arg1, "max.damage:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_DAMAGE) and \ not item.spectype.is_set(merc.ADV_FINISHED): if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(0, 1000): item.spectype.set_bit(merc.ADV_FAILED) else: item.value[2] = int(arg2) item.points += int(arg2) * 0.5 elif game_utils.str_cmp(arg1, "move") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_ACTION) and \ item.value[1] == merc.ACTION_NONE and not item.spectype.is_set(merc.ADV_FINISHED): item.value[1] = merc.ACTION_MOVE item.points += 500 elif game_utils.str_cmp(arg1, "mob:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_ACTION) and \ item.value[1] == merc.ACTION_NONE and not item.specytpe.is_set(merc.ADV_FINISHED): item.value[1] = merc.ACTION_MOB mobile = ch.get_char_world2(arg2) if not arg2 or not mobile: item.spectype.set_bit(merc.ADV_FAILED) else: item.value[2] = mobile.vnum item.points += 500 elif game_utils.str_cmp(arg1, "object:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_ACTION) and \ item.value[1] == merc.ACTION_NONE and not item.spectype.is_set(merc.ADV_FINISHED): item.value[1] = merc.ACTION_OBJECT obj = ch.get_char_world2(arg2) if not arg2 or not obj or obj.flags.artifact or obj.questowner: item.spectype.set_bit(merc.ADV_FAILED) else: item.value[2] = obj.vnum item.points += 500 elif game_utils.str_cmp(arg1, "apply:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \ not item.spectype.is_set(merc.ADV_FINISHED): if not arg2: item.spectype.set_bit(merc.ADV_FAILED) elif game_utils.str_cmp(arg2, ["strength", "str"]) and not state_checks.is_set(item.value[1], merc.ADV_STR): state_checks.set_bit(item.value[1], merc.ADV_STR) elif game_utils.str_cmp(arg2, ["dexterity", "dex"]) and not state_checks.is_set(item.value[1], merc.ADV_DEX): state_checks.set_bit(item.value[1], merc.ADV_DEX) elif game_utils.str_cmp(arg2, ["intelligence", "int"]) and not state_checks.is_set(item.value[1], merc.ADV_INT): state_checks.set_bit(item.value[1], merc.ADV_INT) elif game_utils.str_cmp(arg2, ["wisdom", "wis"]) and not state_checks.is_set(item.value[1], merc.ADV_WIS): state_checks.set_bit(item.value[1], merc.ADV_WIS) elif game_utils.str_cmp(arg2, ["constitution", "con"]) and not state_checks.is_set(item.value[1], merc.ADV_CON): state_checks.set_bit(item.value[1], merc.ADV_CON) elif game_utils.str_cmp(arg2, "mana") and not state_checks.is_set(item.value[1], merc.ADV_MANA): state_checks.set_bit(item.value[1], merc.ADV_MANA) elif game_utils.str_cmp(arg2, ["hp", "hits", "hitpoints"]) and not state_checks.is_set(item.value[1], merc.ADV_HIT): state_checks.set_bit(item.value[1], merc.ADV_HIT) elif game_utils.str_cmp(arg2, ["move", "movement"]) and not state_checks.is_set(item.value[1], merc.ADV_MOVE): state_checks.set_bit(item.value[1], merc.ADV_MOVE) elif game_utils.str_cmp(arg2, ["ac", "armour", "armor"]) and not state_checks.is_set(item.value[1], merc.ADV_AC): state_checks.set_bit(item.value[1], merc.ADV_AC) elif game_utils.str_cmp(arg2, ["hr", "hit", "hitroll"]) and not state_checks.is_set(item.value[1], merc.ADV_HITROLL): state_checks.set_bit(item.value[1], merc.ADV_HITROLL) elif game_utils.str_cmp(arg2, ["dr", "dam", "damroll"]) and not state_checks.is_set(item.value[1], merc.ADV_DAMROLL): state_checks.set_bit(item.value[1], merc.ADV_DAMROLL) elif game_utils.str_cmp(arg2, ["save", "save.spell", "save_spell"]) and not state_checks.is_set(item.value[1], merc.ADV_SAVING_SPELL): state_checks.set_bit(item.value[1], merc.ADV_SAVING_SPELL) else: item.spectype.set_bit(merc.ADV_FAILED) return item.points += 25 elif game_utils.str_cmp(arg1, "affect:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \ not item.spectype.is_set(merc.ADV_FINISHED): if not arg2: item.spectype.set_bit(merc.ADV_FAILED) elif game_utils.str_cmp(arg2, ["blind", "blindness"]) and not state_checks.is_set(item.value[3], merc.AFF_BLIND): state_checks.set_bit(item.value[3], merc.AFF_BLIND) elif game_utils.str_cmp(arg2, ["invis", "invisible", "invisibility"]) and not state_checks.is_set(item.value[3], merc.AFF_BLIND): state_checks.set_bit(item.value[3], merc.AFF_INVISIBLE) elif game_utils.str_cmp(arg2, "detect.evil") and not state_checks.is_set(item.value[3], merc.AFF_DETECT_EVIL): state_checks.set_bit(item.value[3], merc.AFF_DETECT_EVIL) elif game_utils.str_cmp(arg2, ["detect.invis", "detect.invisible", "detect.invisibility"]) and not state_checks.is_set(item.value[3], merc.AFF_DETECT_INVIS): state_checks.set_bit(item.value[3], merc.AFF_DETECT_INVIS) elif game_utils.str_cmp(arg2, "detect.magic") and not state_checks.is_set(item.value[3], merc.AFF_DETECT_MAGIC): state_checks.set_bit(item.value[3], merc.AFF_DETECT_MAGIC) elif game_utils.str_cmp(arg2, "detect.hidden") and not state_checks.is_set(item.value[3], merc.AFF_DETECT_HIDDEN): state_checks.set_bit(item.value[3], merc.AFF_DETECT_HIDDEN) elif game_utils.str_cmp(arg2, ["shadowplane", "shadow.plane"]) and not state_checks.is_set(item.value[3], merc.AFF_SHADOWPLANE): state_checks.set_bit(item.value[3], merc.AFF_SHADOWPLANE) elif game_utils.str_cmp(arg2, ["sanct", "sanctuary"]) and not state_checks.is_set(item.value[3], merc.AFF_SANCTUARY): state_checks.set_bit(item.value[3], merc.AFF_SANCTUARY) elif game_utils.str_cmp(arg2, "faerie.fire") and not state_checks.is_set(item.value[3], merc.AFF_FAERIE_FIRE): state_checks.set_bit(item.value[3], merc.AFF_FAERIE_FIRE) elif game_utils.str_cmp(arg2, ["infravision", "infrared", "infra"]) and not state_checks.is_set(item.value[3], merc.AFF_SANCTUARY): state_checks.set_bit(item.value[3], merc.AFF_SANCTUARY) elif game_utils.str_cmp(arg2, "curse") and not state_checks.is_set(item.value[3], merc.AFF_CURSE): state_checks.set_bit(item.value[3], merc.AFF_CURSE) elif game_utils.str_cmp(arg2, ["flaming", "burning"]) and not state_checks.is_set(item.value[3], merc.AFF_FLAMING): state_checks.set_bit(item.value[3], merc.AFF_FLAMING) elif game_utils.str_cmp(arg2, "poison") and not state_checks.is_set(item.value[3], merc.AFF_POISON): state_checks.set_bit(item.value[3], merc.AFF_POISON) elif game_utils.str_cmp(arg2, ["protect", "protection"]) and not state_checks.is_set(item.value[3], merc.AFF_PROTECT): state_checks.set_bit(item.value[3], merc.AFF_PROTECT) elif game_utils.str_cmp(arg2, "ethereal") and not state_checks.is_set(item.value[3], merc.AFF_ETHEREAL): state_checks.set_bit(item.value[3], merc.AFF_ETHEREAL) elif game_utils.str_cmp(arg2, "sneak") and not state_checks.is_set(item.value[3], merc.AFF_SNEAK): state_checks.set_bit(item.value[3], merc.AFF_SNEAK) elif game_utils.str_cmp(arg2, "hide") and not state_checks.is_set(item.value[3], merc.AFF_HIDE): state_checks.set_bit(item.value[3], merc.AFF_HIDE) elif game_utils.str_cmp(arg2, "sleep") and not state_checks.is_set(item.value[3], merc.AFF_SLEEP): state_checks.set_bit(item.value[3], merc.AFF_SLEEP) elif game_utils.str_cmp(arg2, "charm") and not state_checks.is_set(item.value[3], merc.AFF_CHARM): state_checks.set_bit(item.value[3], merc.AFF_CHARM) elif game_utils.str_cmp(arg2, ["fly", "flying"]) and not state_checks.is_set(item.value[3], merc.AFF_FLYING): state_checks.set_bit(item.value[3], merc.AFF_FLYING) elif game_utils.str_cmp(arg2, ["passdoor", "pass.door"]) and not state_checks.is_set(item.value[3], merc.AFF_PASS_DOOR): state_checks.set_bit(item.value[3], merc.AFF_PASS_DOOR) elif game_utils.str_cmp(arg2, ["shadowsight", "shadow.sight"]) and not state_checks.is_set(item.value[3], merc.AFF_SHADOWSIGHT): state_checks.set_bit(item.value[3], merc.AFF_SHADOWSIGHT) elif game_utils.str_cmp(arg2, ["web", "webbed"]) and not state_checks.is_set(item.value[3], merc.AFF_WEBBED): state_checks.set_bit(item.value[3], merc.AFF_WEBBED) else: item.spectype.set_bit(merc.ADV_FAILED) return item.points += 25 elif game_utils.str_cmp(arg1, "bonus:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \ not item.spectype.is_set(merc.ADV_FINISHED): if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(0, 100): item.spectype.set_bit(merc.ADV_FAILED) else: item.value[2] = int(arg2) item.points += int(arg2) * 15 elif game_utils.str_cmp(arg1, "duration:") and item.spectype.is_set(merc.ADV_STARTED) and item.spectype.is_set(merc.ADV_AFFECT) and \ item.level == 0 and not item.spectype.is_set(merc.ADV_FINISHED): if not arg2 or not arg2.isdigit() or int(arg2) not in merc.irange(1, 60): item.spectype.set_bit(merc.ADV_FAILED) else: item.level = int(arg2) item.points += int(arg2) * 10 elif game_utils.str_cmp(arg1, ["message.one:", "message.1:"]) and item.spectype.is_set(merc.ADV_STARTED) and \ not item.spectype.is_set(merc.ADV_MESSAGE_1) and not item.spectype.is_set(merc.ADV_FINISHED): if not arg2: item.spectype.set_bit(merc.ADV_FAILED) else: item.spectype.set_bit(merc.ADV_MESSAGE_1) item.chpoweroff = arg2 elif game_utils.str_cmp(arg1, ["message.two:", "message.2:"]) and item.spectype.is_set(merc.ADV_STARTED) and \ not item.spectype.is_set(merc.ADV_MESSAGE_2) and not item.spectype.is_set(merc.ADV_FINISHED): if not arg2: item.spectype.set_bit(merc.ADV_FAILED) else: item.spectype.set_bit(merc.ADV_MESSAGE_2) item.victpoweron = arg2 elif game_utils.str_cmp(arg1, ["message.three:", "message.3:"]) and item.spectype.is_set(merc.ADV_STARTED) and \ not item.spectype.is_set(merc.ADV_MESSAGE_3) and not item.spectype.is_set(merc.ADV_FINISHED): if not arg2: item.spectype.set_bit(merc.ADV_FAILED) else: item.spectype.set_bit(merc.ADV_MESSAGE_3) item.victpoweroff = arg2 elif not item.spectype.is_set(merc.ADV_FINISHED): item.spectype.set_bit(merc.ADV_FAILED) else: return handler_game.act("$n writes something on $p.", ch, item, None, merc.TO_ROOM) ch.send("Ok.\n")