def do_close(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Close what?\n") return # TODO: Verify this section after equipment revamp obj = ch.get_item_here(arg) if obj: # portal stuff */ if obj.item_type == merc.ITEM_PORTAL: if not state_checks.IS_SET(obj.value[1], merc.EX_ISDOOR) or state_checks.IS_SET(obj.value[1], merc.EX_NOCLOSE): ch.send("You can't do that.\n") return if state_checks.IS_SET(obj.value[1], merc.EX_CLOSED): ch.send("It's already closed.\n") return obj.value[1] = state_checks.SET_BIT(obj.value[1], merc.EX_CLOSED) handler_game.act("You close $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n closes $p.", ch, obj, None, merc.TO_ROOM) return # 'close object' */ if obj.item_type != merc.ITEM_CONTAINER: ch.send("That's not a container.\n") return if state_checks.IS_SET(obj.value[1], merc.CONT_CLOSED): ch.send("It's already closed.\n") return if not state_checks.IS_SET(obj.value[1], merc.CONT_CLOSEABLE): ch.send("You can't do that.\n") return obj.value[1] = state_checks.SET_BIT(obj.value[1], merc.CONT_CLOSED) handler_game.act("You close $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n closes $p.", ch, obj, None, merc.TO_ROOM) return door = handler_room.find_door(ch, arg) if handler_room.find_door(ch, arg) >= 0: # 'close door' pexit = ch.in_room.exit[door] if pexit.exit_info.is_set(merc.EX_CLOSED): ch.send("It's already closed.\n") return pexit.exit_info.set_bit(merc.EX_CLOSED) handler_game.act("$n closes the $d.", ch, None, pexit.keyword, merc.TO_ROOM) ch.send("Ok.\n") # close the other side to_room = instance.rooms[pexit.to_room] pexit_rev = to_room.exit[merc.rev_dir[door]] if pexit.to_room else None if to_room and pexit_rev and pexit_rev.to_room == ch.in_room.instance_id: pexit_rev.exit_info.set_bit(merc.EX_CLOSED) for rch_id in to_room.people[:]: rch = instance.characters[rch_id] handler_game.act("The $d closes.", rch, None, pexit_rev.keyword, merc.TO_CHAR)
def is_private(room_instance): if room_instance.owner: return True count = len(room_instance.people) if state_checks.IS_SET(room_instance.room_flags, merc.ROOM_PRIVATE) and count >= 2: return True if state_checks.IS_SET(room_instance.room_flags, merc.ROOM_SOLITARY) and count >= 1: return True if state_checks.IS_SET(room_instance.room_flags, merc.ROOM_IMP_ONLY): return True return False
def get_random_room(ch): room = None while True: room = random.choice(instance.rooms.values()) if ch.can_see_room(room) and not room.is_private() \ and not state_checks.IS_SET(room.room_flags, merc.ROOM_PRIVATE) \ and not state_checks.IS_SET(room.room_flags, merc.ROOM_SOLITARY) \ and not state_checks.IS_SET(room.room_flags, merc.ROOM_SAFE) \ and (ch.is_npc() or ch.act.is_set(merc.ACT_AGGRESSIVE) or not state_checks.IS_SET(room.room_flags, merc.ROOM_LAW)): break return room
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_question(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_NOQUESTION): ch.send("Q/A channel is now ON.\n") ch.comm.rem_bit(merc.COMM_NOQUESTION) else: ch.send("Q/A channel is now OFF.\n") ch.comm.set_bit(merc.COMM_NOQUESTION) else: # question sent, turn Q/A on if it isn't already if ch.comm.is_set(merc.COMM_QUIET): ch.send("You must turn off quiet mode first.\n") return if ch.comm.is_set(merc.COMM_NOCHANNELS): ch.send("The gods have revoked your channel privileges.\n") return ch.comm.rem_bit(merc.COMM_NOQUESTION) ch.send("You question '%s'\n" % argument) for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) and d.character != ch \ and not victim.comm.is_set(merc.COMM_NOQUESTION) and not state_checks.IS_SET(victim.comm, merc.COMM_QUIET): handler_game.act("$n questions '$t'", ch, argument, d.character, merc.TO_VICT, merc.POS_SLEEPING)
def spell_word_of_recall(sn, level, ch, victim, target): # RT recall spell is back */ if victim.is_npc(): return location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE) if not location: victim.send("You are completely lost.\n") return if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NO_RECALL) or victim.is_affected( merc.AFF_CURSE): victim.send("Spell failed.\n") return if victim.fighting: fight.stop_fighting(victim, True) ch.move //= 2 handler_game.act("$n disappears.", victim, None, None, merc.TO_ROOM) victim.in_room.get(victim) location.put(victim) handler_game.act("$n appears in the room.", victim, None, None, merc.TO_ROOM) victim.do_look("auto")
def spell_gate(sn, level, ch, victim, target): # RT ROM-style gate */ victim = ch.get_char_world(handler_magic.target_name) if not victim \ or victim == ch \ or victim.in_room == None \ or not ch.can_see_room(victim.in_room.instance_id) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_SAFE) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_PRIVATE) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_SOLITARY) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NO_RECALL) \ or state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_NO_RECALL) \ or victim.level >= level + 3 \ or (victim.is_clan() and not ch.is_same_clan(victim)) \ or (not victim.is_npc() and victim.level >= merc.LEVEL_HERO) \ or (victim.is_npc() and victim.imm_flags.is_set(merc.IMM_SUMMON)) \ or (victim.is_npc() and handler_magic.saves_spell(level, victim, merc.DAM_OTHER) ): ch.send("You failed.\n") return if ch.pet and ch.in_room == ch.pet.in_room: gate_pet = True else: gate_pet = False handler_game.act("$n steps through a gate and vanishes.", ch, None, None, merc.TO_ROOM) ch.send("You step through a gate and vanish.\n") ch.in_room.get(ch) victim.in_room.put(ch) handler_game.act("$n has arrived through a gate.", ch, None, None, merc.TO_ROOM) ch.do_look("auto") if gate_pet: handler_game.act("$n steps through a gate and vanishes.", ch.pet, None, None, merc.TO_ROOM) instance.characters[ch.pet].send( "You step through a gate and vanish.\n") instance.characters[ch.pet].in_room.get(instance.characters[ch.pet]) ch.in_room.put(instance.characters[ch.pet]) handler_game.act("$n has arrived through a gate.", ch.pet, None, None, merc.TO_ROOM) ch.pet.do_look("auto")
def do_sleep(ch, argument): obj = None if ch.position == merc.POS_SLEEPING: ch.send("You are already sleeping.\n") return elif ch.position == merc.POS_RESTING \ or ch.position == merc.POS_SITTING \ or ch.position == merc.POS_STANDING: if not argument and not ch.on: ch.send("You go to sleep.\n") handler_game.act("$n goes to sleep.", ch, None, None, merc.TO_ROOM) ch.position = merc.POS_SLEEPING else: # find an object and sleep on it if not argument: obj = ch.on else: obj = ch.get_item_list(argument, ch.in_room.items) if obj is None: ch.send("You don't see that here.\n") return if obj.item_type != merc.ITEM_FURNITURE or ( not state_checks.IS_SET(obj.value[2], merc.SLEEP_ON) and not state_checks.IS_SET(obj.value[2], merc.SLEEP_IN) and not state_checks.IS_SET(obj.value[2], merc.SLEEP_AT)): ch.send("You can't sleep on that!\n") return if ch.on != obj and obj.count_users() >= obj.value[0]: handler_game.act("There is no room on $p for you.", ch, obj, None, merc.TO_CHAR, merc.POS_DEAD) return ch.on = obj if state_checks.IS_SET(obj.value[2], merc.SLEEP_AT): handler_game.act("You go to sleep at $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n goes to sleep at $p.", ch, obj, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.SLEEP_ON): handler_game.act("You go to sleep on $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n goes to sleep on $p.", ch, obj, None, merc.TO_ROOM) else: handler_game.act("You go to sleep in $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n goes to sleep in $p.", ch, obj, None, merc.TO_ROOM) ch.position = merc.POS_SLEEPING return elif ch.position == merc.POS_FIGHTING: ch.send("You are already fighting!\n") return
def spell_portal(sn, level, ch, victim, target): victim = ch.get_char_world(handler_magic.target_name) if not victim \ or victim == ch \ or victim.in_room == None \ or not ch.can_see_room(victim.in_room.instance_id) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_SAFE) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_PRIVATE) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_SOLITARY) \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NO_RECALL) \ or state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_NO_RECALL) \ or victim.level >= level + 3 \ or (not victim.is_npc() and victim.level >= merc.LEVEL_HERO) \ or (victim.is_npc() and victim.imm_flags.is_set(merc.IMM_SUMMON)) \ or (victim.is_npc() and handler_magic.saves_spell(level, victim, merc.DAM_NONE) ) \ or (victim.is_clan() and not ch.is_same_clan(victim)): ch.send("You failed.\n") return stone = ch.slots.held if not ch.is_immortal() and (stone is None or stone.item_type != merc.ITEM_WARP_STONE): ch.send("You lack the proper component for this spell.\n") return if stone and stone.item_type == merc.ITEM_WARP_STONE: handler_game.act("You draw upon the power of $p.", ch, stone, None, merc.TO_CHAR) handler_game.act("It flares brightly and vanishes! ", ch, stone, None, merc.TO_CHAR) ch.unequip(stone.equipped_to) ch.get(stone) stone.extract() portal = object_creator.create_item( instance.item_templates[merc.OBJ_VNUM_PORTAL], 0) portal.timer = 2 + level // 25 portal.value[3] = victim.in_room.instance_id ch.in_room.put(portal) handler_game.act("$p rises up from the ground.", ch, portal, None, merc.TO_ROOM) handler_game.act("$p rises up before you.", ch, portal, None, merc.TO_CHAR)
def is_dark(room_instance): if room_instance.available_light > 0: return False if state_checks.IS_SET(room_instance.room_flags, merc.ROOM_DARK): return True if room_instance.sector_type == merc.SECT_INSIDE or room_instance.sector_type == merc.SECT_CITY: return False if handler_game.weather_info.sunlight == merc.SUN_SET or handler_game.weather_info.sunlight == merc.SUN_DARK: return True return False
def do_autogold(ch, argument): if ch.is_npc(): return if state_checks.IS_SET(ch.act, merc.PLR_AUTOGOLD): ch.send("Autogold removed.\n") ch.act.rem_bit(merc.PLR_AUTOGOLD) else: ch.send("Automatic gold looting set.\n") ch.act.set_bit(merc.PLR_AUTOGOLD)
def m_reset(pReset, last, level, npc): if pReset.arg1 not in instance.npc_templates.keys(): logger.error("Reset_area: 'M': bad vnum %d.", pReset.arg1) return last, level, npc else: npcTemplate = instance.npc_templates[pReset.arg1] if pReset.arg3 not in instance.room_templates.keys(): logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3) return last, level, npc else: roomInstance_id = instance.instances_by_room[pReset.arg3][0] roomInstance = instance.global_instances[roomInstance_id] if npcTemplate.count >= pReset.arg2: last = False return last, level, npc count = 0 for npc_id in roomInstance.people[:]: npc = instance.global_instances[npc_id] if npc.is_npc(): if npc.vnum == npcTemplate.vnum: count += 1 if count >= pReset.arg4: last = False break if count >= pReset.arg4: return last, level, npc npc = object_creator.create_mobile(npcTemplate) # # * Check for pet shop. # */ if roomInstance.vnum - 1 in instance.room_templates.keys(): prevRoomInstance_id = instance.instances_by_room[roomInstance.vnum - 1][0] prevRoomInstance = instance.global_instances[prevRoomInstance_id] if state_checks.IS_SET(prevRoomInstance.room_flags, merc.ROOM_PET_SHOP): npc.act.set_bit(merc.ACT_PET) # set area */ npc.area = roomInstance.area roomInstance.put(npc) level = max(0, min(npc.level - 2, merc.LEVEL_HERO - 1)) last = True return last, level, npc
def spell_charm_person(sn, level, ch, victim, target): if fight.is_safe(ch, victim): return if victim == ch: ch.send("You like yourself even better! \n") return if ( victim.is_affected( merc.AFF_CHARM) \ or ch.is_affected(merc.AFF_CHARM) \ or level < victim.level \ or state_checks.IS_SET(victim.imm_flags, merc.IMM_CHARM) \ or handler_magic.saves_spell(level, victim, merc.DAM_CHARM) ): return if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_LAW): ch.send("The mayor does not allow charming in the city limits.\n") return if victim.master: handler_ch.stop_follower(victim) handler_ch.add_follower(victim, ch) victim.leader = ch af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level af.duration = game_utils.number_fuzzy(level // 4) af.location = 0 af.modifier = 0 af.bitvector = merc.AFF_CHARM victim.affect_add(af) #TODO: Known broken. Mob will immediately try to fight you after casting this, because this is an offensive spell. #ROM had some stipulation to prevent this combat, possibly in fight.py:is_safe() handler_game.act("Isn't $n just so nice?", ch, None, victim, merc.TO_VICT) if ch is not victim: handler_game.act("$N looks at you with adoring eyes.", ch, None, victim, merc.TO_CHAR)
def do_clantalk(ch, argument): if not ch.is_clan() or ch.clan.independent: ch.send("You aren't in a clan.\n") return if not argument: if state_checks.IS_SET(ch.comm, merc.COMM_NOCLAN): ch.send("Clan channel is now ON\n") ch.comm = state_checks.REMOVE_BIT(ch.comm, merc.COMM_NOCLAN) else: ch.send("Clan channel is now OFF\n") ch.comm = state_checks.SET_BIT(ch.comm, merc.COMM_NOCLAN) return if state_checks.IS_SET(ch.comm, merc.COMM_NOCHANNELS): ch.send("The gods have revoked your channel priviliges.\n") return ch.comm = state_checks.REMOVE_BIT(ch.comm, merc.COMM_NOCLAN) ch.send("You clan '%s'\n" % argument) for d in merc.descriptor_list: if d.is_connected(nanny.con_playing) and d.character != ch and ch.is_same_clan(d.character) \ and not state_checks.IS_SET(d.character.comm, merc.COMM_NOCLAN) and not state_checks.IS_SET(d.character.comm, merc.COMM_QUIET): merc.act("$n clans '$t'", ch, argument, d.character, merc.TO_VICT, merc.POS_DEAD)
def do_tell(ch, argument): if ch.comm.is_set(merc.COMM_NOTELL) or ch.comm.is_set(merc.COMM_DEAF): ch.send("Your message didn't get through.\n") return if ch.comm.is_set(merc.COMM_QUIET): ch.send("You must turn off quiet mode first.\n") return if ch.comm.is_set(merc.COMM_DEAF): ch.send("You must turn off deaf mode first.\n") return argument, arg = game_utils.read_word(argument) if not arg or not argument: ch.send("Tell whom what?\n") return # Can tell to PC's anywhere, but NPC's only in same room. # -- Furey victim = ch.get_char_world(arg) argument = argument.strip() if not victim or ( victim.is_npc() and victim.in_room != ch.in_room ): ch.send("They aren't here.\n") return if victim.desc is None and not victim.is_npc(): handler_game.act("$N seems to have misplaced $S link...try again later.", ch, None, victim, merc.TO_CHAR) buf = "%s tells you '%s'\n" % (state_checks.PERS(ch, victim), argument) victim.buffer.append(buf) return if not (ch.is_immortal() and ch.level > merc.LEVEL_IMMORTAL) and not state_checks.IS_AWAKE(victim): handler_game.act("$E can't hear you.", ch, 0, victim, merc.TO_CHAR) return if (victim.comm.is_set(merc.COMM_QUIET) or state_checks.IS_SET(victim.comm,merc.COMM_DEAF)) and not state_checks.IS_IMMORTAL(ch): handler_game.act("$E is not receiving tells.", ch, 0, victim, merc.TO_CHAR) return if victim.comm.is_set(merc.COMM_AFK): if victim.is_npc(): handler_game.act("$E is AFK, and not receiving tells.", ch, None, victim, merc.TO_CHAR) return handler_game.act("$E is AFK, but your tell will go through when $E returns.", ch, None, victim, merc.TO_CHAR) buf = "%s tells you '%s'\n" % (state_checks.PERS(ch, victim), argument) victim.buffer.append(buf) return handler_game.act("You tell $N '$t'", ch, argument, victim, merc.TO_CHAR) handler_game.act("$n tells you '$t'", ch, argument, victim, merc.TO_VICT, merc.POS_DEAD) victim.reply = ch return
def do_nosummon(ch, argument): if ch.is_npc(): if state_checks.IS_SET(ch.imm_flags, merc.IMM_SUMMON): ch.send("You are no longer immune to summon.\n") ch.imm_flags = state_checks.REMOVE_BIT(ch.imm_flags, merc.IMM_SUMMON) else: ch.send("You are now immune to summoning.\n") ch.imm_flags = state_checks.SET_BIT(ch.imm_flags, merc.IMM_SUMMON) else: if ch.act.is_set(merc.PLR_NOSUMMON): ch.send("You are no longer immune to summon.\n") ch.act.rem_bit(merc.PLR_NOSUMMON) else: ch.send("You are now immune to summoning.\n") ch.act.set_bit(merc.PLR_NOSUMMON)
def do_immtalk(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_NOWIZ): ch.send("Immortal channel is now ON\n") ch.comm.rem_bit(merc.COMM_NOWIZ) else: ch.send("Immortal channel is now OFF\n") ch.comm.set_bit(merc.COMM_NOWIZ) return ch.comm.rem_bit(merc.COMM_NOWIZ) handler_game.act("$n: $t", ch, argument, None, merc.TO_CHAR, merc.POS_DEAD) for d in merc.descriptor_list: if d.is_connected(nanny.con_playing) and state_checks.IS_IMMORTAL(d.character) \ and not state_checks.IS_SET(d.character.comm, merc.COMM_NOWIZ): handler_game.act("$n: $t", ch, argument, d.character, merc.TO_VICT, merc.POS_DEAD)
def aggr_update(): for wch in instance.characters.values(): if wch.is_npc() \ or wch.level >= merc.LEVEL_IMMORTAL \ or wch.in_room is None \ or wch.in_area.empty: continue for ch_id in wch.in_room.people[:]: ch = instance.characters[ch_id] if not ch.is_npc() \ or not ch.act.is_set(merc.ACT_AGGRESSIVE) \ or state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_SAFE) \ or ch.is_affected(merc.AFF_CALM) \ or ch.fighting is not None \ or ch.is_affected(merc.AFF_CHARM) \ or not ch.is_awake() \ or (ch.act.is_set(merc.ACT_WIMPY) and wch.is_awake()) \ or not ch.can_see(wch) \ or random.randint(0, 1) == 0: continue # # * Ok we have a 'wch' player character and a 'ch' npc aggressor. # * Now make the aggressor fight a RANDOM pc victim in the room, # * giving each 'vch' an equal chance of selection. count = 0 victim = None for vch_id in wch.in_room.people[:]: vch = instance.characters[vch_id] if not vch.is_npc() \ and vch.level < merc.LEVEL_IMMORTAL \ and ch.level >= vch.level - 5 \ and (not ch.act.is_set(merc.ACT_WIMPY) or not vch.is_awake()) \ and ch.can_see(vch): if random.randint(0, count) == 0: victim = vch count += 1 if not victim: continue fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
def do_purge(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: for victim_id in ch.in_room.people: victim = instance.characters[victim_id] if victim.is_npc() and not state_checks.IS_SET(victim.act, merc.ACT_NOPURGE) \ and victim != ch: # safety precaution victim.in_room.get(victim) victim.extract(True) for item_id in ch.in_room.items: item = instance.items[item_id] if not item.flags.no_purge: ch.in_room.get(item) item.extract() handler_game.act("$n purges the room!", ch, None, None, merc.TO_ROOM) ch.send("Ok.\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if not victim.is_npc(): if ch == victim: ch.send("Ho ho ho.\n") return if ch.trust <= victim.trust: ch.send("Maybe that wasn't a good idea...\n") victim.send("%s tried to purge you!\n" % ch.name) return handler_game.act("$n disintegrates $N.", ch, 0, victim, merc.TO_NOTVICT) if victim.level > 1: victim.save(logout=True, force=True) d = victim.desc victim.in_room.get(victim) victim.extract(True) if d: comm.close_socket(d) return handler_game.act("$n purges $N.", ch, None, victim, merc.TO_NOTVICT) victim.extract(True) return
def spell_teleport(sn, level, ch, victim, target): if victim.in_room == None \ or state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NO_RECALL) \ or ( victim != ch and victim.imm_flags.is_set(merc.IMM_SUMMON)) \ or ( not ch.is_npc() and victim.fighting is not None ) \ or ( victim != ch \ and ( handler_magic.saves_spell(level - 5, victim, merc.DAM_OTHER))): ch.send("You failed.\n") return random_room = handler_room.get_random_room(victim) if victim != ch: victim.send("You have been teleported! \n") handler_game.act("$n vanishes! ", victim, None, None, merc.TO_ROOM) victim.in_room.get(victim) random_room.put(victim) handler_game.act("$n slowly fades into existence.", victim, None, None, merc.TO_ROOM) victim.do_look("auto")
def do_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 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 random.randint(0, ch.daze) != 0 \ 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, False) 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!\n") if ch.guild.name == 'thief' and (random.randint(1, 99) < 3 * (ch.level // 2)): ch.send("You snuck away safely.\n") else: ch.send("You lost 10 exp.\n") update.gain_exp(ch, -10) fight.stop_fighting(ch, True) return ch.send("PANIC! You couldn't escape!\n") return
def do_shout(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_SHOUTSOFF): ch.send("You can hear shouts again.\n") ch.comm.rem_bit(merc.COMM_SHOUTSOFF) else: ch.send("You will no longer hear shouts.\n") ch.comm.set_bit(merc.COMM_SHOUTSOFF) return if ch.comm.is_set(merc.COMM_NOSHOUT): ch.send("You can't shout.\n") return ch.comm.rem_bit(merc.COMM_SHOUTSOFF) state_checks.WAIT_STATE(ch, 12) handler_game.act("You shout '$T'", ch, None, argument, merc.TO_CHAR) for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) and d.character != ch \ and not victim.comm.is_set(merc.COMM_SHOUTSOFF) and not state_checks.IS_SET(victim.comm, merc.COMM_QUIET): handler_game.act("$n shouts '$t'", ch, argument, d.character, merc.TO_VICT)
def spell_haste(sn, level, ch, victim, target): # RT haste spell */ if state_checks.is_affected(victim, sn) or victim.is_affected( merc.AFF_HASTE) or (victim.is_npc() and state_checks.IS_SET( victim.off_flags, merc.OFF_FAST)): if victim == ch: ch.send("You can't move any faster! \n") else: handler_game.act("$N is already moving as fast as $E can.", ch, None, victim, merc.TO_CHAR) return if victim.is_affected(merc.AFF_SLOW): if not handler_magic.check_dispel(level, victim, const.skill_table["slow"]): if victim != ch: ch.send("Spell failed.\n") victim.send("You feel momentarily faster.\n") return handler_game.act("$n is moving less slowly.", victim, None, None, merc.TO_ROOM) return af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level if victim == ch: af.duration = level // 2 else: af.duration = level // 4 af.location = merc.APPLY_DEX af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32) af.bitvector = merc.AFF_HASTE victim.affect_add(af) victim.send("You feel yourself moving more quickly.\n") handler_game.act("$n is moving more quickly.", victim, None, None, merc.TO_ROOM) if ch != victim: ch.send("Ok.\n")
def do_where(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Players near you:\n") found = False for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) \ and victim \ and not victim.is_npc() \ and victim.in_room \ and not state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NOWHERE) \ and (ch.is_room_owner(victim.in_room) or not victim.in_room.is_private()) \ and victim.in_room.area == ch.in_room.area \ and ch.can_see(victim): found = True ch.send("%-28s %s\n" % (victim.name, victim.in_room.name)) if not found: ch.send("None\n") else: found = False for victim in instance.characters.values(): if victim.in_room \ and victim.in_room.area == ch.in_room.area \ and not victim.is_affected( merc.AFF_HIDE) \ and not victim.is_affected( merc.AFF_SNEAK) \ and ch.can_see(victim) \ and arg in victim.name.lower(): found = True ch.send("%-28s %s\n" % (state_checks.PERS(victim, ch), victim.in_room.name)) break if not found: handler_game.act("You didn't find any $T.", ch, None, arg, merc.TO_CHAR) return
def do_pick(self, argument): ch = self argument, arg = game_utils.read_word(argument) if not arg: ch.send("Pick what?\n") return state_checks.WAIT_STATE(ch, const.skill_table["pick lock"].beats) # look for guards for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if state_checks.IS_NPC(gch) and state_checks.IS_AWAKE(gch) 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 random.randint(1, 99) > ch.get_skill("pick lock"): ch.send("You failed.\n") if ch.is_pc(): ch.check_improve( "pick lock", False, 2) return obj = ch.get_item_here(arg) if obj: # portal stuff if obj.item_type == merc.ITEM_PORTAL: if not state_checks.IS_SET(obj.value[1], merc.EX_ISDOOR): ch.send("You can't do that.\n") return if not state_checks.IS_SET(obj.value[1], merc.EX_CLOSED): ch.send("It's not closed.\n") return if obj.value[4] < 0: ch.send("It can't be unlocked.\n") return if state_checks.IS_SET(obj.value[1], merc.EX_PICKPROOF): ch.send("You failed.\n") return state_checks.REMOVE_BIT(obj.value[1], merc.EX_LOCKED) handler_game.act("You pick the lock on $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n picks the lock on $p.", ch, obj, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve( "pick lock", True, 2) return # 'pick object' if obj.item_type != merc.ITEM_CONTAINER: ch.send("That's not a container.\n") return if not state_checks.IS_SET(obj.value[1], merc.CONT_CLOSED): ch.send("It's not closed.\n") return if obj.value[2] < 0: ch.send("It can't be unlocked.\n") return if not state_checks.IS_SET(obj.value[1], merc.CONT_LOCKED): ch.send("It's already unlocked.\n") return if state_checks.IS_SET(obj.value[1], merc.CONT_PICKPROOF): ch.send("You failed.\n") return state_checks.REMOVE_BIT(obj.value[1], merc.CONT_LOCKED) handler_game.act("You pick the lock on $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n picks the lock on $p.", ch, obj, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve( "pick lock", True, 2) 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) and not ch.is_immortal(): ch.send("It's not closed.\n") return if pexit.key < 0 and not ch.is_immortal(): 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) and not ch.is_immortal(): 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) if ch.is_pc(): ch.check_improve( "pick_lock", True, 2) # unlock the other side to_room = 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 do_get(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if arg2 == "from": argument, arg2 = game_utils.read_word(argument) found = False # Get type. if not arg1: ch.send("Get what?\n") return if not arg2: if not arg1.startswith('all'): # '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' for item_id in ch.in_room.items: item = instance.items[item_id] if (len(arg1) == 3 or arg1[4:] in 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 arg2.startswith("all"): 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 elif container.item_type == merc.ITEM_CORPSE_PC: if not ch.can_loot(container): ch.send("You can't do that.\n") return elif container.item_type != merc.ITEM_CONTAINER and container.item_type != 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 arg1.startswith('all'): # 'get obj container' item = ch.get_item_list(arg1, container.inventory) if not item is None: 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 arg1[4:] in item.name) and ch.can_see_item(item): found = True if container.vnum == merc.OBJ_VNUM_PIT and not ch.is_immortal(): ch.send("Don't be so greedy!\n") return 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)
def spell_heat_metal(sn, level, ch, victim, target): fail = True if not handler_magic.saves_spell(level + 2, victim, merc.DAM_FIRE) \ and not state_checks.IS_SET(victim.imm_flags, merc.IMM_FIRE): total_items = set({}) total_items.update([an_item for an_item in victim.equipped.values()]) total_items.update(victim.contents) for item_id in total_items: item = instance.items[item_id] if random.randint(1, 2 * level) > item.level \ and not handler_magic.saves_spell(level, victim, merc.DAM_FIRE) \ and not item.flags.no_n_metal and not item.flags.burn_proof: if item.item_type == merc.ITEM_ARMOR: if item.equipped_to: # remove the item */ if victim.can_drop_item(item) \ and (item.weight // 10) < random.randint(1, 2 * victim.stat(merc.STAT_DEX)) \ and victim.unequip(item.equipped_to, True): handler_game.act( "$n yelps and throws $p to the ground! ", victim, item, None, merc.TO_ROOM) handler_game.act( "You remove and drop $p before it burns you.", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 3) victim.get(item) victim.in_room.put(item) fail = False else: # stuck on the body! ouch! */ handler_game.act("Your skin is seared by $p! ", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level)) fail = False else: # drop it if we can */ if victim.can_drop_item(item): handler_game.act( "$n yelps and throws $p to the ground! ", victim, item, None, merc.TO_ROOM) handler_game.act( "You and drop $p before it burns you.", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 6) victim.get(item) victim.in_room.put(item) fail = False else: # can! drop */ handler_game.act("Your skin is seared by $p! ", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 2) fail = False if item.item_type == merc.ITEM_WEAPON: if item.equipped_to: # try to drop it */ if item.flags.flaming: continue if victim.can_drop_item(item) and victim.unequip( item.equipped_to, True): handler_game.act( "$n is burned by $p, and throws it to the ground.", victim, item, None, merc.TO_ROOM) victim.send( "You throw your red-hot weapon to the ground! \n" ) dam += 1 victim.get(item) victim.in_room.put(item) fail = False else: # YOWCH! */ victim.send("Your weapon sears your flesh! \n") dam += random.randint(1, item.level) fail = False else: # drop it if we can */ if victim.can_drop_item(item): handler_game.act( "$n throws a burning hot $p to the ground! ", victim, item, None, merc.TO_ROOM) handler_game.act( "You and drop $p before it burns you.", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 6) victim.get(item) victim.in_room.put(item) fail = False else: # can! drop */ handler_game.act("Your skin is seared by $p! ", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 2) fail = False if fail: ch.send("Your spell had no effect.\n") victim.send("You feel momentarily warmer.\n") else: # damage! */ if handler_magic.saves_spell(level, victim, merc.DAM_FIRE): dam = 2 * dam // 3 fight.damage(ch, victim, dam, sn, merc.DAM_FIRE, True)
def npc_update(): # Examine all mobs. */ for npc in instance.characters.values(): if not npc.is_npc() or npc.in_room is None or npc.is_affected( merc.AFF_CHARM): continue if instance.area_templates[npc.in_room.area] and not npc.act.is_set( merc.ACT_UPDATE_ALWAYS): continue # Examine call for special procedure */ if npc.spec_fun: if npc.spec_fun(npc): continue if npc.pShop: # give him some gold */ if (npc.gold * 100 + npc.silver) < npc.wealth: npc.gold += npc.wealth * random.randint(1, 20) // 5000000 npc.silver += npc.wealth * random.randint(1, 20) // 50000 # That's all for sleeping / busy monster, and empty zones */ if npc.position != merc.POS_STANDING: continue # Scavenge */ if npc.act.is_set( merc.ACT_SCAVENGER ) and npc.in_room.items is not None and random.randint(0, 6) == 0: top = 1 item_best = None for item_id in npc.in_room.items: item = instance.items[item_id] if item.take and npc.can_loot( item) and item.cost > top and item.cost > 0: item_best = item top = item.cost if item_best: item_best.from_environment() item_best.to_environment(npc.instance_id) handler_game.act("$n gets $p.", npc, item_best, None, merc.TO_ROOM) # Wander */ door = random.randint(0, 5) pexit = npc.in_room.exit[door] if not npc.act.is_set(merc.ACT_SENTINEL) \ and random.randint(0, 3) == 0 \ and pexit \ and pexit.to_room \ and not pexit.exit_info.is_set(merc.EX_CLOSED) \ and not state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB) \ and (not npc.act.is_set(merc.ACT_STAY_AREA) or instance.rooms[pexit.to_room].area == npc.in_room.area) \ and (not npc.act.is_set(merc.ACT_OUTDOORS) or not state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_INDOORS)) \ and (not npc.act.is_set(merc.ACT_INDOORS) or state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_INDOORS)): handler_ch.move_char(npc, door, False)
def do_rest(self, argument): ch = self obj = None if ch.position == merc.POS_FIGHTING: ch.send("You are already fighting!\n") return # okay, now that we know we can rest, find an object to rest on if argument: obj = ch.get_item_list(argument, ch.in_room.items) if not obj: ch.send("You don't see that here.\n") return else: obj = ch.on if obj: if obj.item_type != merc.ITEM_FURNITURE \ or (not state_checks.IS_SET(obj.value[2], merc.REST_ON) and not state_checks.IS_SET(obj.value[2], merc.REST_IN) and not state_checks.IS_SET(obj.value[2], merc.REST_AT)): ch.send("You can't rest on that.\n") return if obj and ch.on != obj and obj.count_users() >= obj.value[0]: handler_game.act("There's no more room on $p.", ch, obj, None, merc.TO_CHAR, merc.POS_DEAD) return ch.on = obj if ch.position == merc.POS_SLEEPING: if ch.is_affected(merc.AFF_SLEEP): ch.send("You can't wake up!\n") return if not obj: ch.send("You wake up and start resting.\n") handler_game.act("$n wakes up and starts resting.", ch, None, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.REST_AT): handler_game.act("You wake up and rest at $p.", ch, obj, None, merc.TO_CHAR, merc.POS_SLEEPING) handler_game.act("$n wakes up and rests at $p.", ch, obj, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.REST_ON): handler_game.act("You wake up and rest on $p.", ch, obj, None, merc.TO_CHAR, merc.POS_SLEEPING) handler_game.act("$n wakes up and rests on $p.", ch, obj, None, merc.TO_ROOM) else: handler_game.act("You wake up and rest in $p.", ch, obj, None, merc.TO_CHAR, merc.POS_SLEEPING) handler_game.act("$n wakes up and rests in $p.", ch, obj, None, merc.TO_ROOM) ch.position = merc.POS_RESTING return elif ch.position == merc.POS_RESTING: ch.send("You are already resting.\n") return elif ch.position == merc.POS_STANDING: if obj is None: ch.send("You rest.\n") handler_game.act("$n sits down and rests.", ch, None, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.REST_AT): handler_game.act("You sit down at $p and rest.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n sits down at $p and rests.", ch, obj, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.REST_ON): handler_game.act("You sit on $p and rest.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n sits on $p and rests.", ch, obj, None, merc.TO_ROOM) else: handler_game.act("You rest in $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n rests in $p.", ch, obj, None, merc.TO_ROOM) ch.position = merc.POS_RESTING return elif ch.position == merc.POS_SITTING: if not obj: ch.send("You rest.\n") handler_game.act("$n rests.", ch, None, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.REST_AT): handler_game.act("You rest at $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n rests at $p.", ch, obj, None, merc.TO_ROOM) elif state_checks.IS_SET(obj.value[2], merc.REST_ON): handler_game.act("You rest on $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n rests on $p.", ch, obj, None, merc.TO_ROOM) else: handler_game.act("You rest in $p.", ch, obj, None, merc.TO_CHAR) handler_game.act("$n rests in $p.", ch, obj, None, merc.TO_ROOM) ch.position = merc.POS_RESTING return
def do_channels(ch, argument): # lists all channels and their status ch.send(" channel status\n") ch.send("---------------------\n") ch.send("gossip ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOGOSSIP): ch.send("ON\n") else: ch.send("OFF\n") ch.send("auction ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOAUCTION): ch.send("ON\n") else: ch.send("OFF\n") ch.send("music ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOMUSIC): ch.send("ON\n") else: ch.send("OFF\n") ch.send("Q/A ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOQUESTION): ch.send("ON\n") else: ch.send("OFF\n") ch.send("Quote ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOQUOTE): ch.send("ON\n") else: ch.send("OFF\n") ch.send("grats ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOGRATS): ch.send("ON\n") else: ch.send("OFF\n") if ch.is_immortal(): ch.send("god channel ") if not state_checks.IS_SET(ch.comm, merc.COMM_NOWIZ): ch.send("ON\n") else: ch.send("OFF\n") ch.send("shouts ") if not state_checks.IS_SET(ch.comm, merc.COMM_SHOUTSOFF): ch.send("ON\n") else: ch.send("OFF\n") ch.send("tells ") if not state_checks.IS_SET(ch.comm, merc.COMM_DEAF): ch.send("ON\n") else: ch.send("OFF\n") ch.send("quiet mode ") if state_checks.IS_SET(ch.comm, merc.COMM_QUIET): ch.send("ON\n") else: ch.send("OFF\n") if state_checks.IS_SET(ch.comm, merc.COMM_AFK): ch.send("You are AFK.\n") if state_checks.IS_SET(ch.comm, merc.COMM_SNOOP_PROOF): ch.send("You are immune to snooping.\n") if ch.lines != merc.PAGELEN: if ch.lines: ch.send("You display %d lines of scroll.\n" % ch.lines + 2) else: ch.send("Scroll buffering is off.\n") if ch.prompt: ch.send("Your current prompt is: %s\n" % ch.prompt) if state_checks.IS_SET(ch.comm, merc.COMM_NOSHOUT): ch.send("You cannot shout.\n") if state_checks.IS_SET(ch.comm, merc.COMM_NOTELL): ch.send("You cannot use tell.\n") if state_checks.IS_SET(ch.comm, merc.COMM_NOCHANNELS): ch.send("You cannot use channels.\n") if state_checks.IS_SET(ch.comm, merc.COMM_NOEMOTE): ch.send("You cannot show emotions.\n")