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_kill(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Kill whom?\n") return victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return # Allow player killing # if not IS_NPC(victim) and not IS_SET(victim.act, PLR_KILLER) and not IS_SET(victim.act, PLR_THIEF): # ch.send("You must MURDER a player.\n") # return if victim == ch: ch.send("You hit yourself. Ouch!\n") fight.multi_hit(ch, ch, merc.TYPE_UNDEFINED) return if fight.is_safe(ch, victim): return if victim.fighting and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: handler_game.act("$N is your beloved master.", ch, None, victim, merc.TO_CHAR) return if ch.position == merc.POS_FIGHTING: ch.send("You do the best you can!\n") return state_checks.WAIT_STATE(ch, 1 * merc.PULSE_VIOLENCE) fight.check_killer(ch, victim) fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) return
def spec_ogre_member(ch): if not ch.is_awake() or state_checks.IS_AFFECTED(ch, merc.AFF_CALM) \ or not ch.in_room or state_checks.IS_AFFECTED(ch, merc.AFF_CHARM) or ch.fighting: return False count = 0 victim = None # find an troll to beat up */ for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if not vch.is_npc() or ch == vch: continue if vch.vnum == MOB_VNUM_PATROLMAN: return False if vch.group == GROUP_VNUM_TROLLS and ch.level > vch.level - 2 and not fight.is_safe(ch, vch): if random.randint(0, count) == 0: victim = vch count += 1 if victim is None: return False messages = ["$n yells 'I've been looking for you, punk!'", "With a scream of rage, $n attacks $N.'", "$n says 'What's Troll filth like you doing around here?'", "$n cracks his knuckles and says 'Do ya feel lucky?'", "$n says 'There's no cops to save you this time!'", "$n says 'Time to join your brother, spud.'", "$n says 'Let's rock.'"] message = random.choice(messages) handler_game.act(message, ch, None, victim, merc.TO_ALL) fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) return True
def do_split(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Split how much?\n") return amount_gold = 0 amount_silver = 0 if arg1.isdigit(): amount_silver = int(arg1) if arg2.isdigit(): amount_gold = int(arg2) if amount_gold < 0 or amount_silver < 0: ch.send("Your group wouldn't like that.\n") return if amount_gold == 0 and amount_silver == 0: ch.send("You hand out zero coins, but no one notices.\n") return if ch.gold < amount_gold or ch.silver < amount_silver: ch.send("You don't have that much to split.\n") return members = 0 for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if gch.is_same_group(ch) and not state_checks.IS_AFFECTED(gch, merc.AFF_CHARM): members += 1 if members < 2: ch.send("Just keep it all.\n") return share_silver = amount_silver // members extra_silver = amount_silver % members share_gold = amount_gold // members extra_gold = amount_gold % members if share_gold == 0 and share_silver == 0: ch.send("Don't even bother, cheapskate.\n") return ch.silver -= amount_silver ch.silver += share_silver + extra_silver ch.gold -= amount_gold ch.gold += share_gold + extra_gold if share_silver > 0: ch.send("You split %d silver coins. Your share is %d silver.\n" % (amount_silver, share_silver + extra_silver)) if share_gold > 0: ch.send("You split %d gold coins. Your share is %d gold.\n" % (amount_gold, share_gold + extra_gold)) if share_gold == 0: buf = "$n splits %d silver coins. Your share is %d silver." % (amount_silver, share_silver) elif share_silver == 0: buf = "$n splits %d gold coins. Your share is %d gold." % (amount_gold, share_gold) else: buf = '$n splits %d silver and %d gold coins, giving you %d silver and %d gold.\n' % ( amount_silver, amount_gold, share_silver, share_gold) for gch_id in ch.in_room.people: gch = instance.characters[gch_id] if gch != ch and gch.is_same_group(ch) and not state_checks.IS_AFFECTED(gch, merc.AFF_CHARM): handler_game.act(buf, ch, None, gch, merc.TO_VICT) gch.gold += share_gold gch.silver += share_silver return
def do_quit(ch, argument): if ch.is_npc(): return if ch.position == merc.POS_FIGHTING: ch.send("No way! You are fighting.\n") return if ch.position < merc.POS_STUNNED: ch.send("You're not DEAD yet.\n") return ch.send("Alas, all good things must come to an end.\n") handler_game.act("$n has left the game.", ch, None, None, merc.TO_ROOM) logger.info("%s has quit.", ch.name) handler_game.wiznet("$N rejoins the real world.", ch, None, merc.WIZ_LOGINS, 0, ch.trust) # After extract_char the ch is no longer valid! ch.save(logout=True, force=True) #save.legacy_save_char_obj(ch) id = ch.id d = ch.desc ch.extract(True) if d is not None: comm.close_socket(d) # toast evil cheating bastards for d in merc.descriptor_list[:]: tch = handler_ch.CH(d) if tch and tch.id == id: tch.extract(True) comm.close_socket(d) return
def find_door(ch, arg): if arg == "n" or arg == "north": door = 0 elif arg == "e" or arg == "east": door = 1 elif arg == "s" or arg == "south": door = 2 elif arg == "w" or arg == "west": door = 3 elif arg == "u" or arg == "up": door = 4 elif arg == "d" or arg == "down": door = 5 else: for door in range(0, 5): pexit = ch.in_room.exit[door] if pexit and pexit.exit_info.is_set(merc.EX_ISDOOR) and pexit.keyword \ and arg in pexit.keyword: return door handler_game.act("I see no $T here.", ch, None, arg, merc.TO_CHAR) return -1 pexit = ch.in_room.exit[door] if not pexit: handler_game.act("I see no door $T here.", ch, None, arg, merc.TO_CHAR) return -1 if not pexit.exit_info.is_set(merc.EX_ISDOOR): ch.send("You can't do that.\n") return -1 return door
def do_follow(ch, argument): # RT changed to allow unlimited following and follow the NOFOLLOW rules argument, arg = game_utils.read_word(argument) if not arg: ch.send("Follow whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.send("They aren't here.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master: handler_game.act("But you'd rather follow $N!", ch, None, ch.master, merc.TO_CHAR) return if victim == ch: if ch.master is None: ch.send("You already follow yourself.\n") return handler_ch.stop_follower(ch) return if not victim.is_npc() \ and victim.act.is_set(merc.PLR_NOFOLLOW) \ and not ch.is_immortal(): handler_game.act("$N doesn't seem to want any followers.\n", ch, None, victim, merc.TO_CHAR) return ch.act.rem_bit(merc.PLR_NOFOLLOW) if ch.master: handler_ch.stop_follower(ch) handler_ch.add_follower(ch, victim) return
def do_disconnect(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Disconnect whom?\n") return if arg.isdigit(): desc = int(arg) for d in merc.descriptor_list: if d.descriptor == desc: comm.close_socket(d) ch.send("Ok.\n") return victim = ch.get_char_world(arg) if not victim: ch.send("They aren't here.\n") return if victim.desc is None: handler_game.act("$N doesn't have a descriptor.", ch, None, victim, merc.TO_CHAR) return for d in merc.descriptor_list: if d == victim.desc: comm.close_socket(d) ch.send("Ok.\n") return logger.warn("BUG: Do_disconnect: desc not found.") ch.send("Descriptor not found!\n") return
def spell_chill_touch(sn, level, ch, victim, target): dam_each = [0, 0, 0, 6, 7, 8, 9, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if not handler_magic.saves_spell(level, victim, merc.DAM_COLD): handler_game.act("$n turns blue and shivers.", victim, None, None, merc.TO_ROOM) af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level af.duration = 6 af.location = merc.APPLY_STR af.modifier = -1 af.bitvector = 0 victim.affect_join(af) else: dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_COLD, True)
def spell_ray_of_truth(sn, level, ch, victim, target): if ch.is_evil(): victim = ch ch.send("The energy explodes inside you! \n") if victim != ch: handler_game.act("$n raises $s hand, and a blinding ray of light shoots forth! ", ch, None, None, merc.TO_ROOM) ch.send("You raise your hand and a blinding ray of light shoots forth! \n") if state_checks.IS_GOOD(victim): handler_game.act("$n seems unharmed by the light.", victim, None, victim, merc.TO_ROOM) victim.send("The light seems powerless to affect you.\n") return dam = game_utils.dice(level, 10) if handler_magic.saves_spell(level, victim, merc.DAM_HOLY): dam = dam // 2 align = victim.alignment align -= 350 if align < -1000: align = -1000 + (align + 1000) // 3 dam = (dam * align * align) // 1000000 fight.damage(ch, victim, dam, sn, merc.DAM_HOLY, True) const.skill_table['blindness'].spell_fun('blindness', 3 * level // 4, ch, victim, merc.TARGET_CHAR)
def do_fill(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Fill what?\n") return obj = ch.get_item_carry(arg, ch) if not obj: ch.send("You do not have that item.\n") return for f_id in ch.in_room.items: f = instance.items[f_id] if f.item_type == merc.ITEM_FOUNTAIN: fountain = f break if not fountain: ch.send("There is no fountain here!\n") return if obj.item_type != merc.ITEM_DRINK_CON: ch.send("You can't fill that.\n") return if obj.value[1] != 0 and obj.value[2] != fountain.value[2]: ch.send("There is already another liquid in it.\n") return if obj.value[1] >= obj.value[0]: ch.send("Your container is full.\n") return handler_game.act("You fill $p with %s from $P." % const.liq_table[fountain.value[2]].name, ch, obj, fountain, merc.TO_CHAR) handler_game.act("$n fills $p with %s from $P." % const.liq_table[fountain.value[2]].name, ch, obj, fountain, merc.TO_ROOM) obj.value[2] = fountain.value[2] obj.value[1] = obj.value[0] return
def spell_holy_word(sn, level, ch, victim, target): # RT really nasty high-level attack spell */ handler_game.act("$n utters a word of divine power! ", ch, None, None, merc.TO_ROOM) ch.send("You utter a word of divine power.\n") for vch_id in ch.in_room.people: vch = instance.characters[vch_id] if (ch.is_good() and vch.is_good()) or ( ch.is_evil() and vch.is_evil()) or ( ch.is_neutral() and vch.is_neutral()): vch.send("You feel full more powerful.\n") const.skill_table['frenzy'].spell_fun('frenzy', level, ch, vch, merc.TARGET_CHAR) const.skill_table['bless'].spell_fun('bless', level, ch, vch, merc.TARGET_CHAR) elif (ch.is_good() and state_checks.IS_EVIL(vch)) or ( ch.is_evil() and state_checks.IS_GOOD(vch)): if not fight.is_safe_spell(ch, vch, True): const.skill_table['curse'].spell_fun('curse', level, ch, vch, merc.TARGET_CHAR) vch.send("You are struck down! \n") dam = game_utils.dice(level, 6) fight.damage(ch, vch, dam, sn, merc.DAM_ENERGY, True) elif state_checks.IS_NEUTRAL(ch): if not fight.is_safe_spell(ch, vch, True): const.skill_table['curse'].spell_fun('curse', level // 2, ch, vch, merc.TARGET_CHAR) vch.send("You are struck down! \n") dam = game_utils.dice(level, 4) fight.damage(ch, vch, dam, sn, merc.DAM_ENERGY, True) ch.send("You feel drained.\n") ch.move = 0 ch.hit = ch.hit // 2
def spec_thief(ch): if ch.position != merc.POS_STANDING: return False for victim_id in ch.in_room.people[:]: victim = instance.characters[victim_id] if victim.is_npc() or victim.level >= merc.LEVEL_IMMORTAL or random.randint(0,31) != 0 or not ch.can_see(victim): continue if state_checks.IS_AWAKE(victim) and random.randint(0, ch.level) == 0: handler_game.act("You discover $n's hands in your wallet!", ch, None, victim, merc.TO_VICT) handler_game.act("$N discovers $n's hands in $S wallet!", ch, None, victim, merc.TO_NOTVICT) return True else: gold = victim.gold * min(random.randint(1, 20), ch.level / 2) / 100 gold = min(gold, ch.level * ch.level * 10) ch.gold += gold victim.gold -= gold silver = victim.silver * min(random.randint(1, 20), ch.level / 2) / 100 silver = min(silver, ch.level * ch.level * 25) ch.silver += silver victim.silver -= silver return True return False
def nuke_pets(ch): if ch.pet: stop_follower(ch.pet) if instance.characters[ch.pet].in_room: handler_game.act("$N slowly fades away.", ch, None, instance.characters[ch.pet], merc.TO_NOTVICT) instance.characters[ch.pet].extract(True) ch.pet = None return
def spell_create_food(sn, level, ch, victim, target): mushroom = object_creator.create_item(instance.item_templates[merc.OBJ_VNUM_MUSHROOM], 0) mushroom.value[0] = level // 2 mushroom.value[1] = level ch.in_room.put(mushroom) handler_game.act("$p suddenly appears.", ch, mushroom, None, merc.TO_ROOM) handler_game.act("$p suddenly appears.", ch, mushroom, None, merc.TO_CHAR) return
def do_say(ch, argument): if not argument: ch.send("Say what?\n") return act("$n says '$T'", ch, None, argument, merc.TO_ROOM) act("You say '$T'", ch, None, argument, merc.TO_CHAR) pyprogs.emit_signal('say', actor=ch, argument=argument, audience=ch.in_room.people) return
def spell_dispel_magic(sn, level, ch, victim, target): # modified for enhanced use */ if handler_magic.saves_spell(level, victim, merc.DAM_OTHER): victim.send("You feel a brief tingling sensation.\n") ch.send("You failed.\n") return spells = {'armor': None, 'bless': None, 'blindness': '$n is no longer blinded', 'calm': '$n no longer looks so peaceful...', 'change sex': '$n looks more like $mself again.', 'charm person': '$n regains $s free will.', 'chill touch': '$n looks warmer', 'curse': None, 'detect evil': None, 'detect good': None, 'detect hidden': None, 'detect invis': None, 'detect magic': None, 'faerie fire': "$n's outline fades", 'fly': '$n falls to the ground! ', 'frenzy': "$n no longer looks so wild.", 'giant strength': "$n no longer looks so mighty.", 'haste': '$n is no longer moving so quickly', 'infravision': None, 'invis': '$n fades into existence.', 'mass invis': '$n fades into existence', 'pass door': None, 'protection evil': None, 'protection good': None, 'sanctuary': "The white aura around $n's body vanishes.", 'shield': 'The shield protecting $n vanishes', 'sleep': None, 'slow': '$n is no longer moving so slowly.', 'stone skin': "$n's skin regains its normal texture.", 'weaken': "$n looks stronger."} for k, v in spells.items(): if handler_magic.check_dispel(level, victim, const.skill_table[k]): if v: handler_game.act(v, victim, None, None, merc.TO_ROOM) found = True if victim.is_affected( merc.AFF_SANCTUARY) and not handler_magic.saves_dispel(level, victim.level, -1) and not state_checks.is_affected(victim, const.skill_table[ "sanctuary"]): state_checks.REMOVE_BIT(victim.affected_by, merc.AFF_SANCTUARY) handler_game.act("The white aura around $n's body vanishes.", victim, None, None, merc.TO_ROOM) found = True if found: ch.send("Ok.\n") else: ch.send("Spell failed.\n")
def do_pose(ch, argument): if ch.is_npc(): return band = merc.LEVEL_HERO // len(pose_table['to_ch'][ch.guild.name]) level = min(ch.level, merc.LEVEL_HERO) // band choice = random.randint(0, level) handler_game.act(pose_table['to_ch'][ch.guild.name][choice], ch, None, None, merc.TO_CHAR) handler_game.act(pose_table['to_others'][ch.guild.name][choice], ch, None, None, merc.TO_ROOM) return
def add_follower(ch, master): if ch.master: logger.error("BUG: Add_follower: non-null master.") return ch.master = master.instance_id ch.leader = None if master.can_see(ch): handler_game.act("$n now follows you.", ch, None, master, merc.TO_VICT) handler_game.act("You now follow $N.", ch, None, master, merc.TO_CHAR) return
def do_emote(ch, argument): if not ch.is_npc() and ch.comm.is_set(merc.COMM_NOEMOTE): ch.send("You can't show your emotions.\n") return if not argument: ch.send("Emote what?\n") return handler_game.act("$n $T", ch, None, argument, merc.TO_ROOM) handler_game.act("$n $T", ch, None, argument, merc.TO_CHAR) return
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 show_char_to_char_1(victim, ch): if victim.can_see(ch): if ch == victim: handler_game.act("$n looks at $mself.", ch, None, None, merc.TO_ROOM) else: handler_game.act("$n looks at you.", ch, None, victim, merc.TO_VICT) handler_game.act("$n looks at $N.", ch, None, victim, merc.TO_NOTVICT) if victim.description: ch.send(victim.description + "\n") else: handler_game.act("You see nothing special about $M.", ch, None, victim, merc.TO_CHAR) if victim.max_hit > 0: percent = (100 * victim.hit) // victim.max_hit else: percent = -1 buf = state_checks.PERS(victim, ch) if percent >= 100: buf += " is in excellent condition.\n" elif percent >= 90: buf += " has a few scratches.\n" elif percent >= 75: buf += " has some small wounds and bruises.\n" elif percent >= 50: buf += " has quite a few wounds.\n" elif percent >= 30: buf += " has some big nasty wounds and scratches.\n" elif percent >= 15: buf += " looks pretty hurt.\n" elif percent >= 0: buf += " is in awful condition.\n" else: buf += " is bleeding to death.\n" buf = buf.capitalize() ch.send(buf) handler_game.act("$N is using:", ch, None, victim, merc.TO_CHAR) for location, instance_id in victim.equipped.items(): if not instance_id: continue item = instance.items[instance_id] if item: if ch.can_see_item(item): if item.flags.two_handed and victim.equipped['off_hand'] == item.instance_id and 'off_hand' in location: continue else: if ch.can_see_item(item): ch.send(merc.eq_slot_strings[location]) ch.send(handler_item.format_item_to_char(item, ch, True) + "\n") if victim != ch and not ch.is_npc() \ and random.randint(1, 99) < ch.get_skill("peek"): ch.send("\nYou peek at the inventory:\n") if ch.is_pc(): ch.check_improve('peek', True, 4) show_list_to_char(victim.inventory, ch, True, True) return
def do_compare(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Compare what to what?\n") return obj1 = ch.get_item_carry(arg1, ch) if not obj1: ch.send("You do not have that item.\n") return obj2 = None if not arg2: for obj2 in ch.inventory[:]: if obj2.equipped_to and ch.can_see_item(obj2) and obj1.item_type == obj2.item_type \ and (obj1.equips_to & obj2.equips_to & ~merc.ITEM_TAKE) != 0: break if not obj2: ch.send("You aren't wearing anything comparable.\n") return else: obj2 = ch.get_item_carry(arg2, ch) if not obj2: ch.send("You do not have that item.\n") return msg = None value1 = 0 value2 = 0 if obj1 is obj2: msg = "You compare $p to itself. It looks about the same." elif obj1.item_type != obj2.item_type: msg = "You can't compare $p and $P." else: if obj1.item_type == merc.ITEM_ARMOR: value1 = obj1.value[0] + obj1.value[1] + obj1.value[2] value2 = obj2.value[0] + obj2.value[1] + obj2.value[2] elif obj1.item_type == merc.ITEM_WEAPON: value1 = (1 + obj1.value[2]) * obj1.value[1] value2 = (1 + obj2.value[2]) * obj2.value[1] else: msg = "You can't compare $p and $P." if msg is None: if value1 == value2: msg = "$p and $P look about the same." elif value1 > value2: msg = "$p looks better than $P." else: msg = "$p looks worse than $P." handler_game.act(msg, ch, obj1, obj2, merc.TO_CHAR) return
def do_report(ch, argument): ch.send("You say 'I have %d/%d hp %d/%d mana %d/%d mv %d xp.'\n" % ( ch.hit, ch.max_hit, ch.mana, ch.max_mana, ch.move, ch.max_move, ch.exp )) buf = "$n says 'I have %d/%d hp %d/%d mana %d/%d mv %d xp.'" % ( ch.hit, ch.max_hit, ch.mana, ch.max_mana, ch.move, ch.max_move, ch.exp ) handler_game.act(buf, ch, None, None, merc.TO_ROOM) return
def spell_cure_blindness(sn, level, ch, victim, target): if not state_checks.is_affected(victim, const.skill_table['blindness']): if victim == ch: ch.send("You aren't blind.\n") else: handler_game.act("$N doesn't appear to be blinded.", ch, None, victim, merc.TO_CHAR) return if handler_magic.check_dispel(level, victim, const.skill_table['blindness']): victim.send("Your vision returns!\n") handler_game.act("$n is no longer blinded.", victim, None, None, merc.TO_ROOM) else: ch.send("Spell failed.\n")
def spell_cancellation(sn, level, ch, victim, target): found = False level += 2 if (not ch.is_npc() and victim.is_npc() and not ( ch.is_affected(merc.AFF_CHARM) and ch.master == victim)) \ or (ch.is_npc() and not victim.is_npc()): ch.send("You failed, try dispel magic.\n") return # unlike dispel magic, the victim gets NO save */ # begin running through the spells */ spells = {'armor': None, 'bless': None, 'blindness': '$n is no longer blinded', 'calm': '$n no longer looks so peaceful...', 'change sex': '$n looks more like $mself again.', 'charm person': '$n regains $s free will.', 'chill touch': '$n looks warmer', 'curse': None, 'detect evil': None, 'detect good': None, 'detect hidden': None, 'detect invis': None, 'detect magic': None, 'faerie fire': "$n's outline fades", 'fly': '$n falls to the ground! ', 'frenzy': "$n no longer looks so wild.", 'giant strength': "$n no longer looks so mighty.", 'haste': '$n is no longer moving so quickly', 'infravision': None, 'invisibility': '$n fades into existence.', 'mass invis': '$n fades into existence', 'pass door': None, 'protection evil': None, 'protection good': None, 'sanctuary': "The white aura around $n's body vanishes.", 'shield': 'The shield protecting $n vanishes', 'sleep': None, 'slow': '$n is no longer moving so slowly.', 'stone skin': "$n's skin regains its normal texture.", 'weaken': "$n looks stronger."} for k, v in spells.items(): if handler_magic.check_dispel(level, victim, const.skill_table[k]): if v: handler_game.act(v, victim, None, None, merc.TO_ROOM) found = True if found: ch.send("Ok.\n") else: ch.send("Spell failed.\n")
def spell_cure_poison(sn, level, ch, victim, target): if not state_checks.is_affected(victim, const.skill_table['poison']): if victim == ch: ch.send("You aren't poisoned.\n") else: handler_game.act("$N doesn't appear to be poisoned.", ch, None, victim, merc.TO_CHAR) return if handler_magic.check_dispel(level, victim, const.skill_table['poison']): victim.send("A warm feeling runs through your body.\n") handler_game.act("$n looks much better.", victim, None, None, merc.TO_ROOM) return ch.send("Spell failed.\n")
def do_practice(ch, argument): temp, argument = game_utils.read_word(argument) if ch.is_npc(): return if not argument: col = 0 for sn, skill in const.skill_table.items(): if ch.level < skill.skill_level[ch.guild.name] \ or sn not in ch.learned or ch.learned[sn] < 1: # skill is not known continue ch.send("%-18s %3d%% " % (skill.name, ch.learned[sn])) col += 1 if col % 3 == 0: ch.send("\n") if col % 3 != 0: ch.send("\n") ch.send("You have %d practice sessions left.\n" % ch.practice) else: if not ch.is_awake(): ch.send("In your dreams, or what?\n") return practitioner = None for mob_id in ch.in_room.people: mob = instance.characters[mob_id] if mob.is_npc() and mob.act.is_set(merc.ACT_PRACTICE): practitioner = mob if not practitioner: ch.send("You can't do that here.\n") return else: mob = practitioner if ch.practice <= 0: ch.send("You have no practice sessions left.\n") return skill = state_checks.prefix_lookup(const.skill_table, argument) if not skill or not ch.is_npc() \ and (ch.level < skill.skill_level[ch.guild.name] or ch.learned[skill.name] < 1 \ or skill.rating[ch.guild.name] == 0): ch.send("You can't practice that.\n") return adept = 100 if ch.is_npc() else ch.guild.skill_adept if ch.learned[skill.name] >= adept: ch.send("You are already learned at %s.\n" % skill.name) else: ch.practice -= 1 ch.learned[skill.name] += const.int_app[ch.stat(merc.STAT_INT)].learn // skill.rating[ ch.guild.name] if ch.learned[skill.name] < adept: handler_game.act("You practice $T.", ch, None, skill.name, merc.TO_CHAR) handler_game.act("$n practices $T.", ch, None, skill.name, merc.TO_ROOM) else: ch.learned[skill.name] = adept handler_game.act("You are now learned at $T.", ch, None, skill.name, merc.TO_CHAR) handler_game.act("$n is now learned at $T.", ch, None, skill.name, merc.TO_ROOM) return
def spell_cure_disease(sn, level, ch, victim, target): if not state_checks.is_affected(victim, const.skill_table['plague']): if victim == ch: ch.send("You aren't ill.\n") else: handler_game.act("$N doesn't appear to be diseased.", ch, None, victim, merc.TO_CHAR) return if handler_magic.check_dispel(level, victim, const.skill_table['plague']): victim.send("Your sores vanish.\n") handler_game.act("$n looks relieved as $s sores vanish.", victim, None, None, merc.TO_ROOM) return ch.send("Spell failed.\n")
def spec_janitor(ch): if not ch.is_awake(): return False for trash_id in ch.in_room.inventory[:]: trash = instance.items[trash_id] if not trash.flags.take or not ch.can_loot(trash): continue if trash.item_type == merc.ITEM_DRINK_CON or trash.item_type == merc.ITEM_TRASH or trash.cost < 10: handler_game.act("$n picks up some trash.", ch, None, None, merc.TO_ROOM) ch.in_room.get(trash) ch.put(trash) return True return False
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 spell_bless(sn, level, ch, victim, target): # deal with the object case first */ if target == merc.TARGET_ITEM: obj = victim if obj.flags.bless: handler_game.act("$p is already blessed.", ch, obj, send_to=merc.TO_CHAR) return if obj.flags.evil: paf = state_checks.affect_find(obj.affected, "curse") level = obj.level if paf: level = paf.level if not handler_magic.saves_dispel(level, level, 0): if paf: obj.affect_remove(paf) handler_game.act("$p glows a pale blue.", ch, obj, None, merc.TO_ALL) obj.extra_bits = state_checks.REMOVE_BIT( obj.extra_flags, merc.ITEM_EVIL) return else: handler_game.act( "The evil of $p is too powerful for you to overcome.", ch, obj, send_to=merc.TO_CHAR) return af = handler_game.AFFECT_DATA() af.where = merc.TO_OBJECT af.type = sn af.level = level af.duration = 6 + level af.location = merc.APPLY_SAVES af.modifier = -1 af.bitvector = merc.ITEM_BLESS obj.affect_add(af) handler_game.act("$p glows with a holy aura.", ch, obj, send_to=merc.TO_ALL) if obj.wear_loc != merc.WEAR_NONE: ch.saving_throw = ch.saving_throw - 1 return # character target */ if victim.position == merc.POS_FIGHTING or state_checks.is_affected( victim, sn): if victim == ch: ch.send("You are already blessed.\n") else: handler_game.act("$N already has divine favor.", ch, None, victim, merc.TO_CHAR) return af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level af.duration = 6 + level af.location = merc.APPLY_HITROLL af.modifier = level // 8 af.bitvector = 0 victim.affect_add(af) af.location = merc.APPLY_SAVING_SPELL af.modifier = 0 - level // 8 victim.affect_add(af) victim.send("You feel righteous.\n") if ch is not victim: handler_game.act("You grant $N the favor of your god.", ch, None, victim, merc.TO_CHAR)
def spl_continual_light(sn, level, ch, victim, target): light = object_creator.create_item(instance.item_templates[merc.OBJ_VNUM_LIGHT_BALL], 0) ch.in_room.put(light) handler_game.act("$n twiddles $s thumbs and $p appears.", ch, light, None, merc.TO_ROOM) handler_game.act("You twiddle your thumbs and $p appears.", ch, light, None, merc.TO_CHAR)
def do_gain(ch, argument): if ch.is_npc(): return # find a trainer trainer = None for t_id in ch.in_room.people[:]: t = instance.characters[t_id] if t.is_npc() and t.act.is_set(merc.ACT_GAIN): trainer = t if not trainer or not ch.can_see(trainer): ch.send("You can't do that here.\n") return argmod, arg = game_utils.read_word(argument) if not arg: trainer.do_say("Pardon me?") return if "list".startswith(arg): col = 0 ch.send("%-18s %-5s %-18s %-5s %-18s %-5s\n" % ("group", "cost", "group", "cost", "group", "cost")) for gn, group in const.group_table.items(): if gn not in ch.group_known and group.rating[ch.guild.name] > 0: ch.send("%-18s %-5d " % (group.name, group.rating[ch.guild.name])) col += 1 if (col % 3) == 0: ch.send("\n") if (col % 3) != 0: ch.send("\n") ch.send("\n") col = 0 ch.send("%-18s %-5s %-18s %-5s %-18s %-5s\n" % ("skill", "cost", "skill", "cost", "skill", "cost")) for sn, skill in const.skill_table.items(): if sn not in ch.learned \ and skill.rating[ch.guild.name] > 0 \ and skill.spell_fun == magic.spell_null: ch.send( "%-18s %-5d " % (const.skill_table[sn].name, skill.rating[ch.guild.name])) col += 1 if (col % 3) == 0: ch.send("\n") if (col % 3) != 0: ch.send("\n") return if "convert".startswith(arg): if ch.practice < 10: handler_game.act("$N tells you 'You are not yet ready.'", ch, None, trainer, merc.TO_CHAR) return handler_game.act("$N helps you apply your practice to training", ch, None, trainer, merc.TO_CHAR) ch.practice -= 10 ch.train += 1 return if "points".startswith(arg): if ch.train < 2: handler_game.act("$N tells you 'You are not yet ready.'", ch, None, trainer, merc.TO_CHAR) return if ch.points <= 40: handler_game.act("$N tells you 'There would be no point in that.'", ch, None, trainer, merc.TO_CHAR) return handler_game.act( "$N trains you, and you feel more at ease with your skills.", ch, None, trainer, merc.TO_CHAR) ch.train -= 2 ch.points -= 1 ch.exp = ch.exp_per_level(ch.points) * ch.level return if argument.lower() in const.group_table: gn = const.group_table[argument.lower()] if gn.name in ch.group_known: handler_game.act("$N tells you 'You already know that group!'", ch, None, trainer, merc.TO_CHAR) return if gn.rating[ch.guild.name] <= 0: handler_game.act( "$N tells you 'That group is beyond your powers.'", ch, None, trainer, merc.TO_CHAR) return if ch.train < gn.rating[ch.guild.name]: handler_game.act( "$N tells you 'You are not yet ready for that group.'", ch, None, trainer, merc.TO_CHAR) return # add the group skills.gn_add(ch, gn) handler_game.act("$N trains you in the art of $t", ch, gn.name, trainer, merc.TO_CHAR) ch.train -= gn.rating[ch.guild.name] return if argument.lower() in const.skill_table: sn = const.skill_table[argument.lower()] if sn.spell_fun is not None: handler_game.act("$N tells you 'You must learn the full group.'", ch, None, trainer, merc.TO_CHAR) return if sn.name in ch.learned: handler_game.act("$N tells you 'You already know that skill!'", ch, None, trainer, merc.TO_CHAR) return if sn.rating[ch.guild.name] <= 0: handler_game.act( "$N tells you 'That skill is beyond your powers.'", ch, None, trainer, merc.TO_CHAR) return if ch.train < sn.rating[ch.guild.name]: handler_game.act( "$N tells you 'You are not yet ready for that skill.'", ch, None, trainer, merc.TO_CHAR) return # add the skill ch.learned[sn.name] = 1 handler_game.act("$N trains you in the art of $t", ch, sn.name, trainer, merc.TO_CHAR) ch.train -= sn.rating[ch.guild.name] return handler_game.act("$N tells you 'I do not understand...'", ch, None, trainer, merc.TO_CHAR) return
def spl_identify(sn, level, ch, victim, target): item = victim handler_game.act("You examine $p carefully.", ch, item, None, merc.TO_CHAR) handler_game.act("$n examines $p carefully.", ch, item, None, merc.TO_ROOM) extra = item.item_attribute_names if extra and item.item_restriction_names: extra += ", " extra += item.item_restriction_names buf = ["Object '{}' is type {}, extra flags {}.\nWeight is {}, value is {}.\n".format(item.name, item.item_type, extra, item.weight, item.cost)] if item.points > 0 and item.item_type not in [merc.ITEM_QUEST, merc.ITEM_PAGE]: buf += "Quest point value is {}.\n".format(item.points) if item.questmaker and item.questowner: buf += "This object was created by {}, and is owned by {}.\n".format(item.questmaker, item.questowner) elif item.questmaker: buf += "This object was created by {}.\n".format(item.questmaker) elif item.questowner: buf += "This object is owned by {}.\n".format(item.questowner) if item.flags.enchanted: buf += "This item has been enchanted.\n" if item.flags.spellproof: buf += "This item is resistant to offensive spells.\n" if item.flags.demonic: buf += "This item is crafted from demonsteel.\n" elif item.flags.silver: buf += "This item is crafted from gleaming silver.\n" itype = item.item_type if itype in [merc.ITEM_PILL, merc.ITEM_SCROLL, merc.ITEM_POTION]: buf += "Level {} spells of:".format(item.value[0]) for i in item.value: if 0 <= i < merc.MAX_SKILL: buf += " '" + const.skill_table[i].name + "'" buf += ".\n" elif itype == merc.ITEM_QUEST: buf += "Quest point value is {}.\n".format(item.value[0]) elif itype == merc.ITEM_QUESTCARD: buf += "Quest completion reward is {} quest points.\n".format(item.level) elif itype in [merc.ITEM_WAND, merc.ITEM_STAFF]: buf += "Has {}({}) charges of level {}".format(item.value[1], item.value[2], item.value[0]) if 0 <= item.value[3] <= merc.MAX_SKILL: buf += " '" + const.skill_table[item.value[3]].name + "'" buf += ".\n" elif itype == merc.ITEM_WEAPON: buf += "Damage is {} to {} (average {}).\n".format(item.value[1], item.value[2], (item.value[1] + item.value[2]) // 2) if item.value[0] >= 1000: itemtype = item.value[0] - ((item.value[0] // 1000) * 1000) else: itemtype = item.value[0] if itemtype > 0: level_list = [(10, " minor"), (20, " lesser"), (30, "n average"), (40, " greater"), (50, " major"), (51, " supreme")] for (aa, bb) in level_list: if item.level < aa: buf += "{} is a{} spell weapon.\n".format(item.short_descr[0].upper() + item.short_descr[1:], bb) break else: buf += "{} is an ultimate spell weapon.\n".format(item.short_descr[0].upper() + item.short_descr[1:]) if itemtype == 1: buf += "This weapon is dripping with corrosive acid.\n" elif itemtype == 4: buf += "This weapon radiates an aura of darkness.\n" elif itemtype == 30: buf += "This ancient relic is the bane of all evil.\n" elif itemtype == 34: buf += "This vampiric weapon drinks the souls of its victims.\n" elif itemtype == 37: buf += "This weapon has been tempered in hellfire.\n" elif itemtype == 48: buf += "This weapon crackles with sparks of lightning.\n" elif itemtype == 53: buf += "This weapon is dripping with a dark poison.\n" else: buf += "This weapon has been imbued with the power of {}.\n".format(const.skill_table[itemtype].name) itemtype = item.value[0] // 1000 if item.value[0] >= 1000 else 0 if itemtype > 0: if itemtype == 4: buf += "This weapon radiates an aura of darkness.\n" elif itemtype in [27, 2]: buf += "This weapon allows the wielder to see invisible things.\n" elif itemtype in [39, 3]: buf += "This weapon grants the power of flight.\n" elif itemtype in [45, 1]: buf += "This weapon allows the wielder to see in the dark.\n" elif itemtype in [46, 5]: buf += "This weapon renders the wielder invisible to the human eye.\n" elif itemtype in [52, 6]: buf += "This weapon allows the wielder to walk through solid doors.\n" elif itemtype in [54, 7]: buf += "This holy weapon protects the wielder from evil.\n" elif itemtype in [57, 8]: buf += "This ancient weapon protects the wielder in combat.\n" elif itemtype == 9: buf += "This crafty weapon allows the wielder to walk in complete silence.\n" elif itemtype == 10: buf += "This powerful weapon surrounds its wielder with a shield of lightning.\n" elif itemtype == 11: buf += "This powerful weapon surrounds its wielder with a shield of fire.\n" elif itemtype == 12: buf += "This powerful weapon surrounds its wielder with a shield of ice.\n" elif itemtype == 13: buf += "This powerful weapon surrounds its wielder with a shield of acid.\n" elif itemtype == 14: buf += "This weapon protects its wielder from clan DarkBlade guardians.\n" elif itemtype == 15: buf += "This ancient weapon surrounds its wielder with a shield of chaos.\n" elif itemtype == 16: buf += "This ancient weapon regenerates the wounds of its wielder.\n" elif itemtype == 17: buf += "This ancient weapon allows its wielder to move at supernatural speed.\n" elif itemtype == 18: buf += "This razor sharp weapon can slice through armour without difficulty.\n" elif itemtype == 19: buf += "This ancient weapon protects its wearer from player attacks.\n" elif itemtype == 20: buf += "This ancient weapon surrounds its wielder with a shield of darkness.\n" elif itemtype == 21: buf += "This ancient weapon grants superior protection to its wielder.\n" elif itemtype == 22: buf += "This ancient weapon grants its wielder supernatural vision.\n" elif itemtype == 23: buf += "This ancient weapon makes its wielder fleet-footed.\n" elif itemtype == 24: buf += "This ancient weapon conceals its wielder from sight.\n" elif itemtype == 25: buf += "This ancient weapon invokes the power of the beast.\n" else: buf += "This item is bugged...please report it.\n" elif itype == merc.ITEM_ARMOR: buf += "Armor class is {}.\n".format(item.value[0]) if item.value[3] > 0: if item.value[3] == 4: buf += "This object radiates an aura of darkness.\n" elif item.value[3] in [27, 2]: buf += "This item allows the wearer to see invisible things.\n" elif item.value[3] in [39, 3]: buf += "This object grants the power of flight.\n" elif item.value[3] in [45, 1]: buf += "This item allows the wearer to see in the dark.\n" elif item.value[3] in [46, 5]: buf += "This object renders the wearer invisible to the human eye.\n" elif item.value[3] in [52, 6]: buf += "This object allows the wearer to walk through solid doors.\n" elif item.value[3] in [54, 7]: buf += "This holy relic protects the wearer from evil.\n" elif item.value[3] in [57, 8]: buf += "This ancient relic protects the wearer in combat.\n" elif item.value[3] == 9: buf += "This crafty item allows the wearer to walk in complete silence.\n" elif item.value[3] == 10: buf += "This powerful item surrounds its wearer with a shield of lightning.\n" elif item.value[3] == 11: buf += "This powerful item surrounds its wearer with a shield of fire.\n" elif item.value[3] == 12: buf += "This powerful item surrounds its wearer with a shield of ice.\n" elif item.value[3] == 13: buf += "This powerful item surrounds its wearer with a shield of acid.\n" elif item.value[3] == 14: buf += "This object protects its wearer from clan DarkBlade guardians.\n" elif item.value[3] == 15: buf += "This ancient item surrounds its wearer with a shield of chaos.\n" elif item.value[3] == 16: buf += "This ancient item regenerates the wounds of its wearer.\n" elif item.value[3] == 17: buf += "This ancient item allows its wearer to move at supernatural speed.\n" elif item.value[3] == 18: buf += "This powerful item allows its wearer to shear through armour without difficulty.\n" elif item.value[3] == 19: buf += "This powerful item protects its wearer from player attacks.\n" elif item.value[3] == 20: buf += "This ancient item surrounds its wearer with a shield of darkness.\n" elif item.value[3] == 21: buf += "This ancient item grants superior protection to its wearer.\n" elif item.value[3] == 22: buf += "This ancient item grants its wearer supernatural vision.\n" elif item.value[3] == 23: buf += "This ancient item makes its wearer fleet-footed.\n" elif item.value[3] == 24: buf += "This ancient item conceals its wearer from sight.\n" elif item.value[3] == 25: buf += "This ancient item invokes the power of the beast.\n" else: buf += "This item is bugged...please report it.\n" for aff in item.affected: if aff.location != merc.APPLY_NONE and aff.modifier != 0: buf += "Affects {} by {}.\n".format(merc.affect_loc_name(aff.location), aff.modifier) ch.send("".join(buf))
def cmd_eyespy(ch, argument): if ch.head.is_set(merc.LOST_EYE_L) and ch.head.is_set(merc.LOST_EYE_R): ch.send("But you don't have any more eyes to pluck out!\n") return if not ch.head.is_set(merc.LOST_EYE_L) and game_utils.number_range(1, 2) == 1: handler_game.act( "You pluck out your left eyeball and throw it to the ground.", ch, None, None, merc.TO_CHAR) handler_game.act( "$n plucks out $s left eyeball and throws it to the ground.", ch, None, None, merc.TO_ROOM) elif not ch.head.is_set(merc.LOST_EYE_R): handler_game.act( "You pluck out your right eyeball and throw it to the ground.", ch, None, None, merc.TO_CHAR) handler_game.act( "$n plucks out $s right eyeball and throws it to the ground.", ch, None, None, merc.TO_ROOM) else: handler_game.act( "You pluck out your left eyeball and throw it to the ground.", ch, None, None, merc.TO_CHAR) handler_game.act( "$n plucks out $s left eyeball and throws it to the ground.", ch, None, None, merc.TO_ROOM) familiar = ch.familiar if familiar: object_creator.make_part(ch, "eyeball") return mob_index = instance.npc_templates[merc.MOB_VNUM_EYE] if not mob_index: ch.send("Error - please inform an Immortal.\n") return victim = object_creator.create_mobile(mob_index) ch.in_room.put(victim) ch.familiar = victim victim.wizard = ch
def cmd_smother(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return if not arg: ch.send("Smother whom?\n") return victim = ch.get_char_world(arg) if not victim: ch.not_here(arg) return if ch == victim: ch.not_self() return if not victim.is_affected(merc.AFF_FLAMING): ch.send("But they are not on fire!\n") return if game_utils.number_percent() > ch.level * 2: handler_game.act("You try to smother the flames around $N but fail!", ch, None, victim, merc.TO_CHAR) handler_game.act( "$n tries to smother the flames around you but fails!", ch, None, victim, merc.TO_VICT) handler_game.act("$n tries to smother the flames around $N but fails!", ch, None, victim, merc.TO_NOTVICT) if game_utils.number_percent() > 98 and not ch.is_affected( merc.AFF_FLAMING): handler_game.act( "A spark of flame from $N's body sets you on fire!", ch, None, victim, merc.TO_CHAR) handler_game.act( "A spark of flame from your body sets $n on fire!", ch, None, victim, merc.TO_VICT) handler_game.act( "A spark of flame from $N's body sets $n on fire!", ch, None, victim, merc.TO_NOTVICT) ch.affected_by.set_bit(merc.AFF_FLAMING) ch.humanity() return handler_game.act("You manage to smother the flames around $M!", ch, None, victim, merc.TO_CHAR) handler_game.act("$n manages to smother the flames around you!", ch, None, victim, merc.TO_VICT) handler_game.act("$n manages to smother the flames around $N!", ch, None, victim, merc.TO_NOTVICT) victim.affected_by.rem_bit(merc.AFF_FLAMING) ch.humanity()
def cmd_give(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Give what to whom?\n") return if arg1.isdigit(): # 'give NNNN coins victim' amount = int(arg1) if amount <= 0 or (not game_utils.str_cmp(arg2, ["coins", "coin"])): ch.send("Sorry, you can't do that.\n") return argument, arg2 = game_utils.read_word(argument) if not arg2: ch.send("Give what to whom?\n") return victim = ch.get_char_room(arg2) if not victim: ch.not_here(arg2) return if victim.is_affected(merc.AFF_ETHEREAL): ch.send("You cannot give things to ethereal people.\n") return if ch.gold < amount: ch.send("You haven't got that much gold.\n") return ch.gold -= amount victim.gold += amount handler_game.act("$n gives you some gold.", ch, None, victim, merc.TO_VICT) handler_game.act("$n gives $N some gold.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("You give $N some gold.", ch, None, victim, merc.TO_CHAR) ch.send("Ok.\n") ch.save(force=True) victim.save(force=True) return item = ch.get_item_carry(arg1) if not item: ch.send("You do not have that item.\n") return if item.equipped_to: ch.send("You must remove it first.\n") return victim = ch.get_char_room(arg2) if not victim: ch.not_here(arg2) return if not ch.can_drop_item(item): ch.send("You can't let go of it.\n") return if victim.is_affected(merc.AFF_ETHEREAL): ch.send("You cannot give things to ethereal people.\n") return if victim.carry_number + item.get_number() > victim.can_carry_n(): handler_game.act("$N has $S hands full.", ch, None, victim, merc.TO_CHAR) return if victim.carry_weight + item.get_weight() > victim.can_carry_w(): handler_game.act("$N can't carry that much weight.", ch, None, victim, merc.TO_CHAR) return if not victim.can_see_item(item): handler_game.act("$N can't see it.", ch, None, victim, merc.TO_CHAR) return ch.get(item) victim.put(item) handler_game.act("$n gives $p to $N.", ch, item, victim, merc.TO_NOTVICT) handler_game.act("$n gives you $p.", ch, item, victim, merc.TO_VICT) handler_game.act("You give $p to $N.", ch, item, victim, merc.TO_CHAR) ch.save(force=True) victim.save(force=True)
def cmd_gag(ch, argument): argument, arg = game_utils.read_word(argument) victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if victim == ch and not victim.extra.is_set( merc.EXTRA_GAGGED) and victim.extra.is_set(merc.EXTRA_TIED_UP): ch.send("You cannot gag yourself!\n") return if not victim.extra.is_set(merc.EXTRA_TIED_UP) and not victim.extra.is_set( merc.EXTRA_GAGGED): ch.send("You can only gag someone who is tied up!\n") return if not victim.extra.is_set(merc.EXTRA_GAGGED): handler_game.act("You place a gag over $N's mouth.", ch, None, victim, merc.TO_CHAR) handler_game.act("$n places a gag over $N's mouth.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n places a gag over your mouth.", ch, None, victim, merc.TO_VICT) victim.extra.set_bit(merc.EXTRA_GAGGED) return if ch == victim: handler_game.act("You remove the gag from your mouth.", ch, None, victim, merc.TO_CHAR) handler_game.act("$n removes the gag from $s mouth.", ch, None, victim, merc.TO_ROOM) victim.extra.rem_bit(merc.EXTRA_GAGGED) return handler_game.act("You remove the gag from $N's mouth.", ch, None, victim, merc.TO_CHAR) handler_game.act("$n removes the gag from $N's mouth.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n removes the gag from your mouth.", ch, None, victim, merc.TO_VICT) victim.extra.rem_bit(merc.EXTRA_GAGGED)
def cmd_crack(ch, argument): item = ch.get_eq("right_hand") if not item or item.vnum != merc.OBJ_VNUM_SEVERED_HEAD: item = ch.get_eq("left_hand") if not item or item.vnum != merc.OBJ_VNUM_SEVERED_HEAD: ch.send("You are not holding any heads.\n") return handler_game.act("You hurl $p at the floor.", ch, item, None, merc.TO_CHAR) handler_game.act("$n hurls $p at the floor.", ch, item, None, merc.TO_ROOM) handler_game.act("$p cracks open, leaking brains out across the floor.", ch, item, None, merc.TO_CHAR) if item.chobj: handler_game.act("$p cracks open, leaking brains out across the floor.", ch, item, item.chobj, merc.TO_NOTVICT) handler_game.act("$p crack open, leaking brains out across the floor.", ch, item, item.chobj, merc.TO_VICT) else: handler_game.act("$p cracks open, leaking brains out across the floor.", ch, item, None, merc.TO_ROOM) crack_head(ch, item, item.name) ch.get(item) item.extract()
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 cmd_practice(ch, argument): temp, argument = game_utils.read_word(argument) if ch.is_npc(): return if not argument: buf = [] col = 0 ch.update_skills() for sn, skill in const.skill_table.items(): if sn not in ch.learned: continue buf += "{:<18} {:3}% ".format(skill.name, ch.learned[sn]) col += 1 if col % 3 == 0: buf += "\n" if col % 3 != 0: buf += "\n" buf += "You have {:,} exp left.\n".format(ch.exp) ch.send("".join(buf)) else: if not ch.is_awake(): ch.send("In your dreams, or what?\n") return if ch.exp <= 0: ch.send("You have no exp left.\n") return skill = state_checks.prefix_lookup(const.skill_table, argument) if not skill or (not ch.is_npc() and ch.level < skill.skill_level): ch.send("You can't practice that.\n") return if ch.learned[skill.name] >= 100: ch.send("You are already an adept of {}.\n".format(skill.name)) elif ch.learned[skill.name] > 0 and (ch.learned[skill.name] // 2) > ch.exp: ch.send("You need {} exp to increase {} any more.\n".format( ch.learned[skill.name] // 2, skill.name)) elif ch.learned[skill.name] == 0 and ch.exp < 500: ch.send("You need 500 exp to increase {}.\n".format(skill.name)) else: if ch.learned[skill.name] == 0: ch.exp -= 500 ch.learned[skill.name] += ch.stat(merc.STAT_INT) else: ch.exp -= ch.learned[skill.name] // 2 ch.learned[skill.name] += const.int_app[ch.stat( merc.STAT_INT)].learn if ch.learned[skill.name] < 100: handler_game.act("You practice $T.", ch, None, skill.name, merc.TO_CHAR) else: ch.learned[skill.name] = 100 handler_game.act("You are now an adept of $T.", ch, None, skill.name, merc.TO_CHAR)
def cmd_teach(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return if not ch.is_mage(): ch.huh() return if ch.level == merc.LEVEL_APPRENTICE: ch.send("You don't know enough to teach another.\n") return if not arg: ch.send("Teach whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if ch == victim: ch.not_self() return if victim.is_npc(): ch.not_npc() return if victim.is_immortal(): ch.not_imm() return if victim.is_mage(): ch.send("They are already a mage.\n") return if victim.level != merc.LEVEL_AVATAR: ch.send("You can only teach avatars.\n") return if victim.is_vampire() or victim.vampaff.is_set(merc.VAM_MORTAL): ch.send("You are unable to teach vampires!\n") return if victim.is_werewolf(): ch.send("You are unable to teach werewolves!\n") return if victim.is_demon() or victim.special.is_set(merc.SPC_CHAMPION): ch.send("You are unable to teach demons!\n") return if victim.is_highlander(): ch.send("You are unable to teach highlanders.\n") return if not victim.immune.is_set(merc.IMM_VAMPIRE): ch.send("You cannot teach an unwilling person.\n") return if ch.exp < 100000: ch.send("You cannot afford the 100000 exp required to teach them.\n") return if victim.exp < 100000: ch.send("They cannot afford the 100000 exp required to learn from you.\n") return ch.exp -= 100000 victim.exp -= 100000 handler_game.act("You teach $N the basics of magic.", ch, None, victim, merc.TO_CHAR) handler_game.act("$n teaches $N the basics of magic.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n teaches you the basics of magic.", ch, None, victim, merc.TO_VICT) victim.level = merc.LEVEL_APPRENTICE victim.trust = merc.LEVEL_APPRENTICE victim.send("You are now an apprentice.\n") victim.lord = ch.name victim.powers[merc.MPOWER_RUNE0] = ch.powers[merc.MPOWER_RUNE0] victim.ch_class = ch.ch_class ch.save(force=True) victim.save(force=True)
def cmd_unlock(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Unlock what?\n") return item = ch.get_item_here(arg) if item: # 'unlock 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 unlocked.\n") return if not ch.valid_key(item.value[2]): ch.send("You lack the key.\n") return if not state_checks.is_set(item.value[1], merc.CONT_LOCKED): ch.send("It's already unlocked.\n") return state_checks.remove_bit(item.value[1], merc.CONT_LOCKED) ch.send("*Click*\n") handler_game.act("$n unlocks $p.", ch, item, None, merc.TO_ROOM) return door = handler_room.find_door(ch, arg) if door >= 0: # 'unlock 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 unlocked.\n") return if not ch.valid_key(pexit.key): ch.send("You lack the key.\n") return if not pexit.exit_info.is_set(merc.EX_LOCKED): ch.send("It's already unlocked.\n") return pexit.exit_info.rem_bit(merc.EX_LOCKED) ch.send("*Click*\n") handler_game.act("$n unlocks the $d.", ch, None, pexit.keyword, merc.TO_ROOM) # unlock 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 spl_polymorph(sn, level, ch, victim, target): if ch.is_affected(merc.AFF_POLYMORPH): ch.send("You cannot polymorph from this form.\n") return if ch.position == merc.POS_FIGHTING or ch.is_affected(sn): return if game_utils.str_cmp(handler_magic.target_name, "frog"): if not ch.is_npc() and ch.stance[0] != -1: ch.cmd_stance("") if ch.mounted == merc.IS_RIDING: ch.cmd_dismount("") handler_game.act("$n polymorphs into a frog!", ch, None, None, merc.TO_ROOM) ch.send("You polymorph into a frog!\n") ch.clear_stats() aff = handler_game.AffectData(type=sn, duration=game_utils.number_range(3, 5), location=merc.APPLY_POLY, modifier=merc.POLY_FROG, bitvector=merc.AFF_POLYMORPH) ch.affect_join(aff) ch.morph = "{} the frog".format(ch.name) elif game_utils.str_cmp(handler_magic.target_name, "fish"): if not ch.is_npc() and ch.stance[0] != -1: ch.cmd_stance("") if ch.mounted == merc.IS_RIDING: ch.cmd_dismount("") handler_game.act("$n polymorphs into a fish!", ch, None, None, merc.TO_ROOM) ch.send("You polymorph into a fish!\n") ch.clear_stats() aff = handler_game.AffectData(type=sn, duration=game_utils.number_range(3, 5), location=merc.APPLY_POLY, modifier=merc.POLY_FISH, bitvector=merc.AFF_POLYMORPH) ch.affect_join(aff) ch.morph = "{} the fish".format(ch.name) elif game_utils.str_cmp(handler_magic.target_name, "raven"): if not ch.is_npc() and ch.stance[0] != -1: ch.cmd_stance("") if ch.mounted == merc.IS_RIDING: ch.cmd_dismount("") handler_game.act("$n polymorphs into a raven!", ch, None, None, merc.TO_ROOM) ch.send("You polymorph into a raven!\n") ch.clear_stats() aff = handler_game.AffectData(type=sn, duration=game_utils.number_range(3, 5), location=merc.APPLY_AC, modifier=-150, bitvector=merc.AFF_POLYMORPH) ch.affect_join(aff) aff.bitvector = merc.AFF_POLYMORPH if ch.is_affected( merc.AFF_FLYING) else (merc.AFF_POLYMORPH + merc.AFF_FLYING) ch.affect_join(aff) aff.location = merc.APPLY_POLY aff.modifier = merc.POLY_RAVEN ch.affect_join(aff) ch.morph = "{} the raven".format(ch.name) else: ch.send("You can polymorph into a frog, a fish, or an raven.\n")
def spl_refresh(sn, level, ch, victim, target): victim.move = min(victim.move + level, victim.max_move) handler_game.act("$n looks less tired.", victim, None, None, merc.TO_ROOM) victim.send("You feel less tired.\n")
def do_steal(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1 or not arg2: ch.send("Steal what from whom?\n") return victim = ch.get_char_room(arg2) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("That's pointless.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.position == merc.POS_FIGHTING: ch.send( "Kill stealing is not permitted.\nYou'd better not -- you might get hit.\n" ) return state_checks.WAIT_STATE(ch, const.skill_table["steal"].beats) percent = random.randint(1, 99) if not state_checks.IS_AWAKE(victim): percent -= 10 elif not victim.can_see(ch): percent += 25 else: percent += 50 if ((ch.level + 7 < victim.level or ch.level - 7 > victim.level) and not victim.is_npc() and not ch.is_npc() ) \ or (not ch.is_npc() and percent > ch.get_skill("steal")) \ or (not ch.is_npc() and not ch.is_clan()): # Failure. ch.send("Oops.\n") ch.affect_strip("sneak") ch.affected_by = ch.affected_by.rem_bit(merc.AFF_SNEAK) handler_game.act("$n tried to steal from you.\n", ch, None, victim, merc.TO_VICT) handler_game.act("$n tried to steal from $N.\n", ch, None, victim, merc.TO_NOTVICT) outcome = random.randint(0, 3) buf = '' if outcome == 0: buf = "%s is a lousy thief!" % ch.name elif outcome == 1: buf = "%s couldn't rob %s way out of a paper bag!" % (ch.name, ( "her" if ch.sex == 2 else "his")) elif outcome == 2: buf = "%s tried to rob me!" % ch.name elif outcome == 3: buf = "Keep your hands out of there, %s!" % ch.name if not state_checks.IS_AWAKE(victim): victim.do_wake("") if state_checks.IS_AWAKE(victim): victim.do_yell(buf) if not ch.is_npc(): if victim.is_npc(): if ch.is_pc(): ch.check_improve("steal", False, 2) fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) else: handler_game.wiznet("$N tried to steal from %s." % victim.name, ch, None, merc.WIZ_FLAGS, 0, 0) if not ch.act.is_set(merc.PLR_THIEF): ch.act.set_bit(merc.PLR_THIEF) ch.send("*** You are now a THIEF!! ***\n") ch.save() return currency = ['coins', 'coin', 'gold', 'silver'] if arg1 in currency: gold = victim.gold * random.randint(1, ch.level) // merc.MAX_LEVEL silver = victim.silver * random.randint(1, ch.level) // merc.MAX_LEVEL if gold <= 0 and silver <= 0: ch.send("You couldn't get any coins.\n") return ch.gold += gold ch.silver += silver victim.silver -= silver victim.gold -= gold if silver <= 0: ch.send("Bingo! You got %d gold coins.\n" % gold) elif gold <= 0: ch.send("Bingo! You got %d silver coins.\n" % silver) else: ch.send("Bingo! You got %d silver and %d gold coins.\n" % (silver, gold)) if ch.is_pc(): ch.check_improve("steal", True, 2) return item = victim.get_item_carry(arg1, ch) if not item: ch.send("You can't find it.\n") return if not ch.can_drop_item( item) or item.flags.shop_inventory or item.level > ch.level: ch.send("You can't pry it away.\n") return if ch.carry_number + item.get_number() > ch.can_carry_n(): ch.send("You have your hands full.\n") return if ch.carry_weight + item.get_weight() > ch.can_carry_w(): ch.send("You can't carry that much weight.\n") return item.get() ch.put(item) handler_game.act("You pocket $p.", ch, item, None, merc.TO_CHAR) if ch.is_pc(): ch.check_improve("steal", True, 2) ch.send("Got it!\n") return
def cmd_say(ch, argument): if ch.head.is_set(merc.LOST_TONGUE): ch.send("You can't speak without a tongue!\n") return if ch.extra.is_set(merc.EXTRA_GAGGED): ch.send("You can't speak with a gag on!\n") return if len(argument) > settings.MAX_INPUT_LENGTH: ch.send("Line too long.\n") return if not argument: ch.send("Say what?\n") return endbit = argument[-1] secbit = argument[-2] if len(argument) > 1 else "" if ch.body.is_set(merc.CUT_THROAT): speak1 = "rasp" speak2 = "rasps" elif not ch.is_npc() and (ch.special.is_set(merc.SPC_WOLFMAN) or ch.polyaff.is_set(merc.POLY_WOLF) or (game_utils.str_cmp(ch.ch_class.name, "vampire") and ch.powers[merc.UNI_RAGE] > 0)): if game_utils.number_percent() > 50: speak1 = "growl" speak2 = "growls" else: speak1 = "snarl" speak2 = "snarls" elif not ch.is_npc() and ch.polyaff.is_set(merc.POLY_BAT): speak1 = "squeak" speak2 = "squeaks" elif not ch.is_npc() and ch.polyaff.is_set(merc.POLY_SERPENT): speak1 = "hiss" speak2 = "hisses" elif (not ch.is_npc() and ch.polyaff.is_set(merc.POLY_FROG)) or ( ch.is_npc() and ch.vnum == merc.MOB_VNUM_FROG): speak1 = "croak" speak2 = "croaks" elif (not ch.is_npc() and ch.polyaff.is_set(merc.POLY_RAVEN)) or ( ch.is_npc() and ch.vnum == merc.MOB_VNUM_RAVEN): speak1 = "squark" speak2 = "squarks" elif ch.is_npc() and ch.vnum == merc.MOB_VNUM_CAT: speak1 = "purr" speak2 = "purrs" elif ch.is_npc() and ch.vnum == merc.MOB_VNUM_DOG: speak1 = "bark" speak2 = "barks" elif game_utils.str_cmp(endbit, "!"): speak1 = "exclaim" speak2 = "exclaims" elif game_utils.str_cmp(endbit, "?"): speak1 = "ask" speak2 = "asks" elif secbit and not game_utils.str_cmp(secbit, ".") and game_utils.str_cmp( endbit, "."): speak1 = "state" speak2 = "states" elif secbit and game_utils.str_cmp(secbit, ".") and game_utils.str_cmp( endbit, "."): speak1 = "mutter" speak2 = "mutters" else: speak1 = "say" speak2 = "says" handler_game.act("You $t '$T'.", ch, speak1, argument, merc.TO_CHAR) poly = "$n {} '$T'.".format(speak2) if ch.in_room.vnum != merc.ROOM_VNUM_IN_OBJECT: handler_game.act(poly, ch, None, argument, merc.TO_ROOM) handler_room.room_text(ch, argument.lower()) return to_players = [ instance.characters[instance_id] for instance_id in ch.in_room.people[:] ] for to in to_players: if not to.desc or not to.is_awake() or ch == to: continue if not ch.is_npc() and ch.chobj and ch.chobj.in_obj and not to.is_npc( ) and to.chobj and to.chobj.in_obj and ch.chobj.in_obj == to.chobj.in_obj: is_ok = True else: is_ok = False if not is_ok: continue if ch.is_npc(): name = ch.short_descr elif not ch.is_npc() and ch.affected_by.is_set(merc.AFF_POLYMORPH): name = ch.morph else: name = ch.name name = name[0].upper() + name[1:] to.send("{} {} '{}'.\n".format(name, speak2, argument)) handler_room.room_text(ch, argument.lower())
def spell_recharge(sn, level, ch, victim, target): obj = victim if obj.item_type != merc.ITEM_WAND and obj.item_type != merc.ITEM_STAFF: ch.send("That item does not carry charges.\n") return if obj.value[3] >= 3 * level // 2: ch.send("Your skills are not great enough for that.\n") return if obj.value[1] == 0: ch.send("That item has already been recharged once.\n") return chance = 40 + 2 * level chance -= obj.value[3] # harder to do high-level spells */ chance -= (obj.value[1] - obj.value[2]) * (obj.value[1] - obj.value[2]) chance = max(level // 2, chance) percent = random.randint(1, 99) if percent < chance // 2: handler_game.act("$p glows softly.", ch, obj, None, merc.TO_CHAR) handler_game.act("$p glows softly.", ch, obj, None, merc.TO_ROOM) obj.value[2] = max(obj.value[1], obj.value[2]) obj.value[1] = 0 return elif percent <= chance: handler_game.act("$p glows softly.", ch, obj, None, merc.TO_CHAR) handler_game.act("$p glows softly.", ch, obj, None, merc.TO_CHAR) chargemax = obj.value[1] - obj.value[2] chargeback = 0 if chargemax > 0: chargeback = max(1, chargemax * percent // 100) obj.value[2] += chargeback obj.value[1] = 0 return elif percent <= min(95, 3 * chance // 2): ch.send("Nothing seems to happen.\n") if obj.value[1] > 1: obj.value[1] -= 1 return else: # whoops! */ handler_game.act("$p glows brightly and explodes! ", ch, obj, None, merc.TO_CHAR) handler_game.act("$p glows brightly and explodes! ", ch, obj, None, merc.TO_ROOM) obj.extract()
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 cmd_quest(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) arg3 = argument if arg1 and game_utils.str_cmp(arg1, "create"): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to create new objects.\n") return if ch.quest == 0: ch.send("You must first earn some quest points.\n") return if not arg2: ch.send( "Syntax: quest create <object> <field>\n" "Object being one of: Light (10 QP), Weapon < type > (50 QP), Armor(30 QP),\n" "Container(10 QP), Boat(10 QP), Fountain < type > (10 QP), Stake(10 QP).\n" ) return type_list = [("light", merc.ITEM_LIGHT, 10), ("weapon", merc.ITEM_WEAPON, 50), (["armor", "armour"], merc.ITEM_ARMOR, 20), ("container", merc.ITEM_CONTAINER, 10), ("boat", merc.ITEM_BOAT, 10), ("fountain", merc.ITEM_FOUNTAIN, 10), ("stake", merc.ITEM_STAKE, 10)] for (aa, bb, cc) in type_list: if game_utils.str_cmp(arg2, aa): add = bb value = 10 break else: ch.cmd_quest("create") return if ch.quest < value: ch.send( "You don't have the required {} quest points.\n".format(value)) return obj_index = instance.item_templates[merc.OBJ_VNUM_PROTOPLASM] if not obj_index: ch.send("Error...missing object, please inform an Immortal.\n") return item = object_creator.create_item(obj_index, 25) item.weight = 1 item.cost = 1000 item.item_type = add if add == merc.ITEM_WEAPON: if not arg3: ch.send( "Please specify weapon type: Slice, Stab, Slash, Whip, Claw, Blast, Pound,\n" "Crush, Pierce, or Suck.\n") item.extract() return wpn_list = [("slice", merc.WPN_SLICE), ("stab", merc.WPN_STAB), ("slash", merc.WPN_SLASH), ("whip", merc.WPN_WHIP), ("claw", merc.WPN_CLAW), ("blast", merc.WPN_BLAST), ("pound", merc.WPN_POUND), ("crush", merc.WPN_CRUSH), ("pierce", merc.WPN_PIERCE), ("suck", merc.WPN_SUCK)] for (aa, bb) in wpn_list: if game_utils.str_cmp(arg3, aa): item.value[3] = bb break else: ch.cmd_quest("create weapon") item.extract() return item.value[1] = 10 item.value[2] = 20 item.level = 50 elif add == merc.ITEM_FOUNTAIN: if not arg3: ch.send( "Please specify fountain contents: Water, Beer, Wine, Ale, Darkale, Whisky,\n" "Firebreather, Specialty, Slime, Milk, Tea, Coffee, Blood, Saltwater.\n" ) item.extract() return item_list = [("water", 0), ("beer", 1), ("wine", 2), ("ale", 3), ("darkale", 4), ("whisky", 5), ("firebreather", 7), ("specialty", 8), ("slime", 9), ("milk", 10), ("tea", 11), ("coffee", 12), ("blood", 13), ("saltwater", 14)] for (aa, bb) in item_list: if game_utils.str_cmp(arg3, aa): item.value[2] = bb break else: ch.cmd_quest("create fountain") item.extract() return item.value[0] = 1000 item.value[1] = 1000 elif add == merc.ITEM_CONTAINER: item.value[0] = 999 elif add == merc.ITEM_LIGHT: item.value[2] = -1 elif add == merc.ITEM_ARMOR: item.value[0] = 15 ch.quest -= value ch.put(item) item.quest.set_bit(merc.QUEST_FREENAME) item.questmaker = ch.name item.questowner = ch.name handler_game.act( "You reach up into the air and draw out a ball of protoplasm.", ch, item, None, merc.TO_CHAR) handler_game.act( "$n reaches up into the air and draws out a ball of protoplasm.", ch, item, None, merc.TO_ROOM) return if not arg1 or not arg2: ch.send( "- - - - - - - - - - ----====[ QUEST ITEM COSTS ]====---- - - - - - - - - - -\n" "Create: Creates a new personalized object, costing between 10 and 50 QP.\n" "Name/Short/Long: Rename the object. 1 QP for all three.\n" "Protection: Sets AC on armour at 1 QP per point.\n" "Min/Max: Sets min/max damage on weapon at 1 QP per point.\n" "Weapon: Sets weapon type for 10 QP.\n" "Extra (add/remove): Glow(1/1), Hum(1/1), Invis(1/1), Anti-Good(1/10),\n" " Anti-Neutral(1/10), Anti-Evil(1/10), Loyal(10/1).\n" "Wear: Select location, costs 20 QP's. Type 'quest <obj> wear' to see locations.\n" "Power: Spell power for spell weapons. Costs 1 QP per power point.\n" "Spell: Spell weapons or affect. Costs 50 QP.\n" "Transporter: Future transportation to that room. Costs 50 QP.\n" "Special: Set activate/twist/press/pull flags.\n" "You-in/You-out/Other-in/Other-out: Renames for transporter actions.\n" "You-wear/You-remove/You-use: What you see when you wear/remove/use.\n" "Other-wear/Other-remove/Other-use: What others see when you wear/remove/use.\n" "Weight: Set objects weight to 1. Costs 10 QP.\n" "Str, Dex, Int, Wis, Con... max = 3 each, at 20 quest points per +1 stat.\n" "Hp, Mana, Move............ max = 25 each, at 5 quest points per point.\n" "Hitroll, Damroll.......... max = 5 each, at 30 quest points per point.\n" "Ac........................ max = -25, at 10 points per point.\n" "- - - - - - - - - - ----====[ QUEST ITEM COSTS ]====---- - - - - - - - - - -\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 in [ merc.ITEM_QUEST, merc.ITEM_AMMO, merc.ITEM_EGG, merc.ITEM_VOODOO, merc.ITEM_MONEY, merc.ITEM_TREASURE, merc.ITEM_TOOL, merc.ITEM_SYMBOL, merc.ITEM_PAGE ] or item.flags.artifact: ch.send("You cannot quest-change that item.\n") return if not ch.is_immortal() and (not item.questowner or not game_utils.str_cmp( ch.name, item.questowner)): ch.send("You can only change an item you own.\n") return # Snarf the value (which need not be numeric). value = int(arg3) if arg3.isdigit() else 0 if game_utils.str_cmp(arg2, "protection"): if not arg3: ch.send("How much armor class?\n") return if item.item_type != merc.ITEM_ARMOR: ch.send("That item is not armor.\n") return if item.item_type == merc.ITEM_ARMOR and (value + item.value[0]) > 15: if item.value[0] < 15: ch.send("The armor class can be increased by {}.\n".format( 15 - item.value[0])) else: ch.send("The armor class cannot be increased any further.\n") return if ch.quest < value: ch.send("You don't have enough quest points.\n") return item.value[0] += value if item.value < 0: item.value[0] = 0 ch.send("Ok.\n") if value < 1: value = 1 ch.quest -= value item.questmaker = ch.name return if game_utils.str_cmp(arg2, "min"): if not arg3: ch.send("How much min damage?\n") return if item.item_type != merc.ITEM_WEAPON: ch.send("That item is not a weapon.\n") return if item.item_type == merc.ITEM_WEAPON and (value + item.value[1]) > 10: if item.value[1] < 10: ch.send("The minimum damage can be increased by {}.\n".format( 10 - item.value[1])) else: ch.send( "The minimum damage cannot be increased any further.\n") return if ch.quest < value: ch.send("You don't have enough quest points.\n") return item.value[1] += value if item.value[1] < 1: item.value[1] = 1 ch.send("Ok.\n") if value < 1: value = 1 ch.quest -= value item.questmaker = ch.name return if game_utils.str_cmp(arg2, "max"): if not arg3: ch.send("How much max damage?\n") return if item.item_type != merc.ITEM_WEAPON: ch.send("That item is not a weapon.\n") return if item.item_type == merc.ITEM_WEAPON and (value + item.value[2]) > 20: if item.value[2] < 20: ch.send("The maximum damage can be increased by {}.\n".format( 20 - item.value[2])) else: ch.send( "The maximum damage cannot be increased any further.\n") return if ch.quest < value: ch.send("You don't have enough quest points.\n") return item.value[2] += value if item.value[2] < 0: item.value[2] = 0 ch.send("Ok.\n") if value < 1: value = 1 ch.quest -= value item.questmaker = ch.name return if game_utils.str_cmp(arg2, "weapon"): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to change weapon types.\n") return if item.item_type == merc.ITEM_WEAPON: if item.flags.relic: ch.send("Not on a relic.\n") return if ch.quest < 10: ch.send("You don't have enough quest points.\n") return if not arg3: ch.send( "Please specify weapon type: Slice, Stab, Slash, Whip, Claw, Blast, Pound,\n" "Crush, Pierce, or Suck.\n") return wpn_list = [("slice", merc.WPN_SLICE), ("stab", merc.WPN_STAB), ("slash", merc.WPN_SLASH), ("whip", merc.WPN_WHIP), ("claw", merc.WPN_CLAW), ("blast", merc.WPN_BLAST), ("pound", merc.WPN_POUND), ("crush", merc.WPN_CRUSH), ("pierce", merc.WPN_PIERCE), ("suck", merc.WPN_SUCK)] for (aa, bb) in wpn_list: if game_utils.str_cmp(arg3, aa): value = bb break else: ch.send( "Please specify weapon type: Slice, Stab, Slash, Whip, Claw, Blast, Pound,\n" "Crush, Pierce, or Suck.\n") return if item.value[3] == value: ch.send("It is already that weapon type.\n") return item.value[3] = value ch.quest -= 10 ch.send("Ok.\n") item.questmaker = ch.name else: ch.send("That item is not a weapon.\n") return if game_utils.str_cmp(arg2, "extra"): if item.flags.relic: ch.send("Not on a relic.\n") return if not arg3: ch.send( "Enter one of: Glow, Hum, Invis, Anti-good, Anti-evil, Anti-neutral, Loyal,\n" "Silver.\n") return if game_utils.str_cmp(arg3, "glow"): value = item.flags.glow add = 1 remove = 1 elif game_utils.str_cmp(arg3, "hum"): value = item.flags.hum add = 1 remove = 1 elif game_utils.str_cmp(arg3, "invis"): value = item.flags.invis add = 1 remove = 1 elif game_utils.str_cmp(arg3, "anti-good"): value = item.flags.anti_good add = 1 remove = 10 elif game_utils.str_cmp(arg3, "anti-evil"): value = item.flags.anti_evil add = 1 remove = 10 elif game_utils.str_cmp(arg3, "anti-neutral"): value = item.flags.anti_neutral add = 1 remove = 10 elif game_utils.str_cmp(arg3, "loyal"): value = item.flags.loyal add = 10 remove = 1 elif game_utils.str_cmp(arg3, "silver"): value = item.flags.silver add = 100 remove = 0 else: ch.send( "Enter one of: Glow, Hum, Invis, Anti-good, Anti-evil, Anti-neutral, Loyal,\n" "Silver.\n") return if game_utils.str_cmp(arg3, "silver"): if item.flags.silver: ch.send("That item is already silver.\n") return if ch.quest < add: ch.send("Sorry, you need {} quest points to set that flag.\n". format(add)) return ch.quest -= add item.flags.silver = True elif value: if ch.quest < remove: ch.send( "Sorry, you need {} quest points to remove that flag.\n". format(remove)) return ch.quest -= remove value = False else: if ch.quest < add: ch.send("Sorry, you need {} quest points to set that flag.\n". format(add)) return ch.quest -= add value = True ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "wear"): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to change object wear locations.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if not arg3: ch.send( "Wear location can be from: Finger, Neck, Body, Head, Legs, Hands, Arms,\n" "About, Waist, Wrist, Hold, Face.\n") return if game_utils.str_cmp(arg3, "finger"): value = merc.ITEM_WEAR_FINGER elif game_utils.str_cmp(arg3, "neck"): value = merc.ITEM_WEAR_NECK elif game_utils.str_cmp(arg3, "body"): value = merc.ITEM_WEAR_BODY elif game_utils.str_cmp(arg3, "head"): value = merc.ITEM_WEAR_HEAD elif game_utils.str_cmp(arg3, "legs"): value = merc.ITEM_WEAR_LEGS elif game_utils.str_cmp(arg3, "feet"): value = merc.ITEM_WEAR_FEET elif game_utils.str_cmp(arg3, "hands"): value = merc.ITEM_WEAR_HANDS elif game_utils.str_cmp(arg3, "arms"): value = merc.ITEM_WEAR_ARMS elif game_utils.str_cmp(arg3, "about"): value = merc.ITEM_WEAR_ABOUT elif game_utils.str_cmp(arg3, "waist"): value = merc.ITEM_WEAR_WAIST elif game_utils.str_cmp(arg3, "wrist"): value = merc.ITEM_WEAR_WRIST elif game_utils.str_cmp(arg3, "hold"): value = merc.ITEM_WIELD elif game_utils.str_cmp(arg3, "face"): value = merc.ITEM_WEAR_FACE else: ch.send( "Wear location can be from: Finger, Neck, Body, Head, Legs, Hands, Arms,\n" "About, Waist, Wrist, Hold, Face.\n") return if item.flags.take: value += 1 if item.wear_flags == value or item.wear_flags == (value + 1): handler_game.act("But $p is already worn in that location!", ch, item, None, merc.TO_CHAR) return if value != merc.ITEM_WIELD and value != ( merc.ITEM_WIELD + 1) and item.item_type == merc.ITEM_WEAPON: handler_game.act("You can only HOLD a weapon.", ch, item, None, merc.TO_CHAR) return if ch.quest < 20 and not (item.vnum == 30037 and item.wear_flags == 1): ch.send("It costs 20 quest points to change a location.\n") return if not (item.vnum == 30037 and item.wear_flags == 1): ch.quest -= 20 item.wear_flags = value ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "replacespell"): if item.flags.relic and not ch.is_demon(): ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if not arg3: ch.send( "Spell weapons: Acid, Dark, Holy, Vampiric, Flaming, Electrified, Poisonous.\n" "Spell affects: Blind, Seeinvis, Fly,Infravision, Invis, Passdoor, Protection,\n" "Sanct, Sneak, Shockshield,Fireshield, Iceshield, Acidshield, Seehidden.\n" ) return spl_list = [("acid", 1, True), ("dark", 4, True), ("holy", 30, True), ("vampiric", 34, True), ("flaming", 37, True), ("electrified", 48, True), ("poisonous", 53, True), ("infravision", 1, False), ("seeinvis", 2, False), ("fly", 3, False), ("blind", 4, False), ("invis", 5, False), ("passdoor", 6, False), ("protection", 7, False), ("sanct", 8, False), ("sneak", 9, False), ("shockshield", 10, False), ("fireshield", 11, False), ("iceshield", 12, False), ("acidshield", 13, False), ("seehidden", 60, False)] for (aa, bb, cc) in spl_list: if game_utils.str_cmp(arg3, aa): weapon = 0 if not cc else cc affect = 0 if not cc else cc break else: ch.send( "Spell weapons: Dark, Holy, Vampiric, Flaming, Electrified, Poisonous.\n" "Spell affects: Blind, Seeinvis, Fly,Infravision, Invis, Passdoor, Protection,\n" "Sanct, Sneak, Shockshield, Fireshield, Iceshield, Acidshield, Seehidden.\n" ) return if item.item_type != merc.ITEM_WEAPON and weapon > 0: ch.send("You can only put that power on a weapon.\n") return elif item.item_type not in [merc.ITEM_WEAPON, merc.ITEM_ARMOR ] and affect > 0: ch.send( "You can only put that power on a weapon or a piece of armour.\n" ) return if ch.quest < 50: ch.send( "It costs 50 quest points to create a spell weapon or affect.\n" ) return if weapon > 0: if item.value[0] >= 1000: item.value[0] = ((item.value[0] // 1000) * 1000) else: item.value[0] = 0 item.value[0] += weapon elif affect > 0: if item.item_type == merc.ITEM_WEAPON: if item.value[0] >= 1000: item.value[0] -= ((item.value[0] // 1000) * 1000) item.value[0] += (affect * 1000) elif item.item_type == merc.ITEM_ARMOR: item.value[3] = affect ch.quest -= 50 ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "spell"): if item.flags.relic and not ch.is_demon(): ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if not arg3: ch.send( "Spell weapons: Acid, Dark, Holy, Vampiric, Flaming, Electrified, Poisonous.\n" "Spell affects: Blind, Seeinvis, Fly, Infravision, Invis, Passdoor, Protection,\n" "Sanct, Sneak, Shockshield, Fireshield, Iceshield, Acidshield, Seehidden.\n" ) return spl_list = [("acid", 1, True), ("dark", 4, True), ("holy", 30, True), ("vampiric", 34, True), ("flaming", 37, True), ("electrified", 48, True), ("poisonous", 53, True), ("infravision", 1, False), ("seeinvis", 2, False), ("fly", 3, False), ("blind", 4, False), ("invis", 5, False), ("passdoor", 6, False), ("protection", 7, False), ("sanct", 8, False), ("sneak", 9, False), ("shockshield", 10, False), ("fireshield", 11, False), ("iceshield", 12, False), ("acidshield", 13, False), ("seehidden", 60, False)] for (aa, bb, cc) in spl_list: if game_utils.str_cmp(arg3, aa): weapon = 0 if not cc else cc affect = 0 if not cc else cc break else: ch.send( "Spell weapons: Acid, Dark, Holy, Vampiric, Flaming, Electrified, Poisonous.\n" "Spell affects: Blind, Seeinvis, Fly, Infravision, Invis, Passdoor, Protection,\n" "Sanct, Sneak, Shockshield, Fireshield, Iceshield, Acidshield, Seehidden.\n" ) return if item.item_type != merc.ITEM_WEAPON and weapon > 0: ch.send("You can only put that power on a weapon.\n") return elif item.item_type not in [merc.ITEM_WEAPON, merc.ITEM_ARMOR ] and affect > 0: ch.send( "You can only put that power on a weapon or a piece of armour.\n" ) return if ch.quest < 50: ch.send( "It costs 50 quest points to create a spell weapon or affect.\n" ) return if weapon > 0: if item.value[0] - ((item.value[0] // 1000) * 1000) != 0: ch.send( "That item already has a spell weapon power. If you wish to replace the \n" "current spell power, use the format: quest <object> replacespell <spell>.\n" ) return if item.value[0] >= 1000: item.value[0] = ((item.value[0] // 1000) * 1000) else: item.value[0] = 0 item.value[0] += weapon elif affect > 0: if item.item_type == merc.ITEM_WEAPON: if item.value[0] >= 1000: ch.send( "That item already has a spell affect power. If you wish to replace the \n" "current spell power, use the format: quest <object> replacespell <spell>.\n" ) return if item.value[0] >= 1000: item.value[0] -= ((item.value[0] // 1000) * 1000) item.value[0] += (affect * 1000) elif item.item_type == merc.ITEM_ARMOR: if item.value[3] > 0: ch.send( "That item already has a spell affect power. If you wish to replace the\n" "current spell power, use the format: quest <object> replacespell <spell>.\n" ) return item.value[3] = affect ch.quest -= 50 ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "power"): if not arg3: ch.send("Please specify the amount of power.\n") return if item.item_type != merc.ITEM_WEAPON: ch.send("Only weapons have a spell power.\n") return if item.level >= 50: ch.send("This weapon can hold no more spell power.\n") return if value + item.level > 50: ch.send("You can only add {} more spell power to this weapon.\n". format(50 - item.level)) return if ch.quest < value: ch.send( "You don't have enough quest points to increase the spell power.\n" ) return item.level += value if item.level < 0: item.level = 0 if value < 1: value = 1 ch.quest -= value ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "weight"): if item.weight < 2: ch.send("You cannot reduce the weight of this item any further.\n") return if ch.quest < 10: ch.send( "It costs 10 quest point to remove the weight of an object.\n") return item.weight = 1 ch.quest -= 10 ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "transporter"): if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if item.spectype.is_set(merc.SITEM_TELEPORTER): ch.send("This item is already a transporter.\n") return elif item.spectype.is_set(merc.SITEM_TRANSPORTER): ch.send("This item is already a teleporter.\n") return elif item.spectype.is_set(merc.SITEM_SPELL): ch.send("This item is already a spell caster.\n") return elif item.spectype.is_set(merc.SITEM_OBJECT): ch.send("This item is already an object creator.\n") return elif item.spectype.is_set(merc.SITEM_MOBILE): ch.send("This item is already a creature creator.\n") return elif item.spectype.is_set(merc.SITEM_ACTION): ch.send("This item is already a commanding device.\n") return if ch.quest < 50: ch.send("It costs 50 quest point to create a transporter.\n") return item.spectype.set_bit(merc.SITEM_ACTIVATE) item.spectype.set_bit(merc.SITEM_TELEPORTER) item.specpower = ch.in_room.vnum ch.quest -= 50 ch.send("Ok.\n") item.questmaker = ch.name item.chpoweron = "You transform into a fine mist and seep into the ground." item.victpoweron = "$n transforms into a fine mist and seeps into the ground." item.chpoweroff = "You seep up from the ground and reform your body." item.victpowreoff = "A fine mist seeps up from the ground and reforms into $n." item.chpoweruse = "You activate $p." item.victpoweruse = "$n activates $p." return if game_utils.str_cmp(arg2, "retransporter"): if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if not item.spectype.is_set(merc.SITEM_TELEPORTER): ch.send("This item is not a transporter.\n") return elif item.spectype.is_set(merc.SITEM_TRANSPORTER): ch.send("This item is already a teleporter.\n") return elif item.spectype.is_set(merc.SITEM_SPELL): ch.send("This item is already a spell caster.\n") return elif item.spectype.is_set(merc.SITEM_OBJECT): ch.send("This item is already an object creator.\n") return elif item.spectype.is_set(merc.SITEM_MOBILE): ch.send("This item is already a creature creator.\n") return elif item.spectype.is_set(merc.SITEM_ACTION): ch.send("This item is already a commanding device.\n") return if ch.quest < 50: ch.send("It costs 50 quest point to create a transporter.\n") return item.spectype.set_bit(merc.SITEM_ACTIVATE) item.spectype.set_bit(merc.SITEM_TELEPORTER) item.specpower = ch.in_room.vnum ch.quest -= 50 ch.send("Ok.\n") item.questmaker = ch.name return if not arg3: ch.send( "- - - - - - - - - - ----====[ QUEST ITEM COSTS ]====---- - - - - - - - - - -\n" "Create: Creates a new personalized object, costing between 10 and 50 QP.\n" "Name/Short/Long: Rename the object. 1 QP for all three.\n" "Protection: Sets AC on armour at 1 QP per point.\n" "Min/Max: Sets min/max damage on weapon at 1 QP per point.\n" "Weapon: Sets weapon type for 10 QP.\n" "Extra (add/remove): Glow(1/1), Hum(1/1), Invis(1/1), Anti-Good(1/10),\n" " Anti-Neutral(1/10), Anti-Evil(1/10), Loyal(10/1).\n" "Wear: Select location, costs 20 QP's. Type 'quest <obj> wear' to see locations.\n" "Power: Spell power for spell weapons. Costs 1 QP per power point.\n" "Spell: Spell weapons or affect. Costs 50 QP.\n" "Transporter: Future transportation to that room. Costs 50 QP.\n" "Special: Set activate/twist/press/pull flags.\n" "You-in/You-out/Other-in/Other-out: Renames for transporter actions.\n" "You-wear/You-remove/You-use: What you see when you wear/remove/use.\n" "Other-wear/Other-remove/Other-use: What others see when you wear/remove/use.\n" "Weight: Set objects weight to 1. Costs 10 QP.\n" "Str, Dex, Int, Wis, Con... max = 3 each, at 20 quest points per +1 stat.\n" "Hp, Mana, Move............ max = 25 each, at 5 quest points per point.\n" "Hitroll, Damroll.......... max = 5 each, at 30 quest points per point.\n" "Ac........................ max = -25, at 10 points per point.\n" "- - - - - - - - - - ----====[ QUEST ITEM COSTS ]====---- - - - - - - - - - -\n" ) return if item.item_type != merc.ITEM_BOOK: if game_utils.str_cmp(arg2, ["hitroll", "hit"]): ch.oset_affect(item, value, merc.APPLY_HITROLL, True) return elif game_utils.str_cmp(arg2, ["damroll", "dam"]): ch.oset_affect(item, value, merc.APPLY_DAMROLL, True) return elif game_utils.str_cmp(arg2, ["armor", "ac"]): ch.oset_affect(item, value, merc.APPLY_AC, True) return elif game_utils.str_cmp(arg2, ["hitpoints", "hp"]): ch.oset_affect(item, value, merc.APPLY_HIT, True) return elif game_utils.str_cmp(arg2, "mana"): ch.oset_affect(item, value, merc.APPLY_MANA, True) return elif game_utils.str_cmp(arg2, ["move", "movement"]): ch.oset_affect(item, value, merc.APPLY_MOVE, True) return elif game_utils.str_cmp(arg2, ["str", "strength"]): ch.oset_affect(item, value, merc.APPLY_STR, True) return elif game_utils.str_cmp(arg2, ["dex", "dexterity"]): ch.oset_affect(item, value, merc.APPLY_DEX, True) return elif game_utils.str_cmp(arg2, ["int", "intelligence"]): ch.oset_affect(item, value, merc.APPLY_INT, True) return elif game_utils.str_cmp(arg2, ["wis", "wisdom"]): ch.oset_affect(item, value, merc.APPLY_WIS, True) return elif game_utils.str_cmp(arg2, ["con", "constitution"]): ch.oset_affect(item, value, merc.APPLY_CON, True) return if game_utils.str_cmp(arg2, "name"): value = 1 if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to rename objects.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if not item.quest.is_set(merc.QUEST_NAME) and (item.quest.is_set( merc.QUEST_SHORT) or item.quest.is_set(merc.QUEST_LONG)): item.quest.set_bit(merc.QUEST_NAME) value = 0 elif item.quest.is_set(merc.QUEST_NAME): item.quest.rem_bit(merc.QUEST_SHORT) item.quest.rem_bit(merc.QUEST_LONG) else: item.quest.set_bit(merc.QUEST_NAME) if item.quest.is_set(merc.QUEST_FREENAME): value = 0 item.quest.rem_bit(merc.QUEST_FREENAME) if ch.quest < value: ch.send("It costs 1 quest point to rename an object.\n") return if len(arg3) < 3: ch.send("Name should be at least 3 characters long.\n") return ch.quest -= value item.name = arg3.lower() ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "short"): value = 1 if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to rename objects.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if not item.quest.is_set(merc.QUEST_SHORT) and (item.quest.is_set( merc.QUEST_NAME) or item.quest.is_set(merc.QUEST_LONG)): item.quest.set_bit(merc.QUEST_SHORT) value = 0 elif item.quest.is_set(merc.QUEST_SHORT): item.quest.rem_bit(merc.QUEST_NAME) item.quest.rem_bit(merc.QUEST_LONG) else: item.quest.set_bit(merc.QUEST_SHORT) if item.quest.is_set(merc.QUEST_FREENAME): value = 0 item.quest.rem_bit(merc.QUEST_FREENAME) if ch.quest < value: ch.send("It costs 1 quest point to rename an object.\n") return if len(arg3) < 3: ch.send("Name should be at least 3 characters long.\n") return ch.quest -= value item.short_descr = arg3 ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "long"): value = 1 if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to rename objects.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if not item.quest.is_set(merc.QUEST_LONG) and (item.quest.is_set( merc.QUEST_NAME) or item.quest.is_set(merc.QUEST_SHORT)): item.quest.set_bit(merc.QUEST_LONG) value = 0 elif item.quest.is_set(merc.QUEST_LONG): item.quest.rem_bit(merc.QUEST_NAME) item.quest.rem_bit(merc.QUEST_SHORT) else: item.quest.set_bit(merc.QUEST_LONG) if item.quest.is_set(merc.QUEST_FREENAME): value = 0 item.quest.rem_bit(merc.QUEST_FREENAME) if ch.quest < value: ch.send("It costs 1 quest point to rename an object.\n") return if len(arg3) < 3: ch.send("Name should be at least 3 characters long.\n") return ch.quest -= value item.description = arg3[0].upper() + arg3[1:] ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "ed"): argument, arg3 = game_utils.read_word(argument) if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not allowed to rename objects.\n") return if item.quest.relic: ch.send("Not on a relic.\n") return if not argument: ch.send("Syntax: quest <object> ed <keyword> <string>\n") return edd = world_classes.ExtraDescrData(keyword=arg3, description=argument[0].upper() + argument[1:] + "\n") item.extra_descr.append(edd) ch.send("Ok.\n") item.questmaker = ch.name return if game_utils.str_cmp(arg2, "special"): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if not arg3: ch.send("Please enter ACTIVATE, TWIST, PRESS or PULL.\n") return arg_list = [("press", merc.SITEM_PRESS), ("activate", merc.SITEM_ACTIVATE), ("pull", merc.SITEM_PULL), ("twist", merc.SITEM_TWIST)] for (aa, bb) in arg_list: if game_utils.str_cmp(arg3, aa): item.spectype.rem_bit(merc.SITEM_ACTIVATE) item.spectype.rem_bit(merc.SITEM_TWIST) item.spectype.rem_bit(merc.SITEM_PRESS) item.spectype.rem_bit(merc.SITEM_PULL) item.spectype.set_bit(bb) break else: ch.send("Please enter ACTIVATE, TWIST, PRESS or PULL.\n") return ch.send("{} flag set.\n".format(arg3[0].upper() + arg3[1:].lower())) return if game_utils.str_cmp(arg2, ["you-out", "you-wear"]): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.quest.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if game_utils.str_cmp( arg2, "you-out") and not item.spectype.is_set(merc.SITEM_TELEPORTER): ch.send("That item is not a transporter.\n") return if game_utils.str_cmp(arg2, "you-wear") and item.spectype.is_set( merc.SITEM_TELEPORTER): ch.send("Not on a transporter.\n") return buf = item.chpoweron if item.chpoweron else "" if game_utils.str_cmp(arg3, "clear"): item.chpoweron = "" elif item.chpowron and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return else: item.chpoweron = buf + "\n" + arg3 else: item.chpoweron = arg3 ch.send("Ok.\n") elif game_utils.str_cmp(arg2, ["other-out", "other-wear"]): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if game_utils.str_cmp(arg2, "other-out") and not item.spectype.is_set( merc.SITEM_TELEPORTER): ch.send("That item is not a transporter.\n") return if game_utils.str_cmp(arg2, "other-wear") and item.spectype.is_set( merc.SITEM_TELEPORTER): ch.send("Not on a transporter.\n") return buf = item.victpoweron if item.victpoweron else "" if game_utils.str_cmp(arg3, "clear"): item.victpoweron = "" elif item.victpoweron and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return else: item.victpoweron = buf + "\n" + arg3 else: item.victpoweron = arg3 ch.send("Ok.\n") elif game_utils.str_cmp(arg2, ["you-in", "you-remove"]): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if game_utils.str_cmp( arg2, "you-in") and not item.spectype.is_set(merc.SITEM_TELEPORTER): ch.send("That item is not a transporter.\n") return if game_utils.str_cmp(arg2, "you-remove") and item.spectype.is_set( merc.SITEM_TELEPORTER): ch.send("Not on a transporter.\n") return buf = item.chpoweroff if item.chpoweroff else "" if game_utils.str_cmp(arg3, "clear"): item.chpoweroff = "" elif item.chpoweroff and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return else: item.chpoweroff = buf + "\n" + arg3 else: item.chpoweroff = arg3 ch.send("Ok.\n") elif game_utils.str_cmp(arg2, ["other-in", "other-remove"]): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return if game_utils.str_cmp(arg2, "other-in") and not item.spectype.is_set( merc.SITEM_TELEPORTER): ch.send("That item is not a transporter.\n") return if game_utils.str_cmp(arg2, "other-remove") and item.spectype.is_set( merc.SITEM_TELEPORTER): ch.send("Not on a transporter.\n") return buf = item.victpoweroff if item.victpoweroff else "" if game_utils.str_cmp(arg3, "clear"): item.victpoweroff = "" elif item.victpoweroff and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return else: item.victpoweroff = buf + "\n" + arg3 else: item.victpoweroff = arg3 ch.send("Ok.\n") elif game_utils.str_cmp(arg2, "you-use"): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return buf = item.chpoewruse if item.chpoweruse else "" if game_utils.str_cmp(arg3, "clear"): item.chpoweruse = "" elif item.chpoweruse and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return else: item.chpoweruse = buf + "\n" + arg3 else: item.chpoweruse = arg3 ch.send("Ok.\n") elif game_utils.str_cmp(arg2, "other-use"): if not ch.extra.is_set(merc.EXTRA_TRUSTED): ch.send("You are not permitted to change an object in this way.\n") return if item.flags.relic: ch.send("Not on a relic.\n") return if item.item_type == merc.ITEM_BOOK: ch.send("Not on a book.\n") return buf = item.victpoweruse if item.victpoweruse else "" if game_utils.str_cmp(arg3, "clear"): item.victpoweruse = "" elif item.victpoweruse and buf: if len(buf) + len(arg3) >= settings.MAX_STRING_LENGTH - 4: ch.send("Line too long.\n") return else: item.victpoweruse = buf + "\n" + arg3 else: item.victpoweruse = arg3 ch.send("Ok.\n")
def con_read_motd(self): ch = self.character ch.send( "\nWelcome to God Wars Mud. May thy blade stay ever sharp, thy soul ever dark.\n" ) self.set_connected(con_playing) if ch.position == merc.POS_FIGHTING: ch.position = merc.POS_STANDING if ch.is_vampire() and (ch.special.is_set(merc.SPC_PRINCE) or ch.powers[merc.UNI_GEN] < 3 or ch.rank > merc.AGE_CHILDE): ch_age = ch.years_old() if ch_age >= 100: ch.rank = merc.AGE_METHUSELAH elif ch_age >= 75: ch.rank = merc.AGE_ELDER elif ch_age >= 50: ch.rank = merc.AGE_ANCILLA else: ch.rank = merc.AGE_NEONATE if ch.level == 0: ch.level = 1 ch.id = game_utils.get_mob_id(npc=False) ch.hit = ch.max_hit ch.mana = ch.max_mana ch.move = ch.max_move ch.title = "the mortal" ch.position = merc.POS_STANDING # TODO: create a player manifest that we can use/check, instead of needing to walk the dir. player_files = list( sys_utils.flatten([x[2] for x in os.walk(settings.PLAYER_DIR)])) if len([x for x in player_files if not x.startswith(".")]) < 1: ch.level = merc.MAX_LEVEL ch.trust = merc.MAX_LEVEL ch.send( "\n\nCongratulations! As the first player to log into this MUD, you are now\n" "the IMPLEMENTOR, the sucker in charge, the place where the buck stops.\n" "Enjoy!\n\n") ch.send( "--------------------------------------------------------------------------------\n" "If you need help, try talking to the spirit of mud school!\n" "--------------------------------------------------------------------------------\n" ) school_id = instance.instances_by_room[merc.ROOM_VNUM_SCHOOL][0] school = instance.rooms[school_id] school.put(ch) ch.cmd_look("auto") else: if ch.obj_vnum != 0: to_instance_id = instance.instances_by_room[ merc.ROOM_VNUM_SCHOOL if not ch._room_vnum else ch. _room_vnum][0] to_instance = instance.rooms[to_instance_id] to_instance.put(ch) ch.bind_char() return elif ch._room_vnum: room_id = instance.instances_by_room.get( merc.ROOM_VNUM_TEMPLE if ch._room_vnum == merc.ROOM_VNUM_LIMBO else ch._room_vnum, None)[0] if room_id: instance.global_instances[room_id].put(ch) elif ch.is_immortal(): to_instance_id = instance.instances_by_room[merc.ROOM_VNUM_CHAT][0] to_instance = instance.rooms[to_instance_id] to_instance.put(ch) elif ch._environment in instance.global_instances.keys(): room = instance.global_instances.get(ch._environment, None) if room and ch._environment == room.instance_id: room.put(ch) elif ch._saved_room_vnum: room_id = instance.instances_by_room.get(ch._saved_room_vnum, None)[0] if room_id: instance.global_instances[room_id].put(ch) else: to_instance_id = instance.instances_by_room[ merc.ROOM_VNUM_TEMPLE][0] to_instance = instance.rooms[to_instance_id] to_instance.put(ch) ch.update_skills() comm.notify("{} has entered the God Wars.".format(ch.name)) handler_game.act("$n has entered the game.", ch, None, None, merc.TO_ROOM) ch.cmd_look("auto") self.send("\n\n" + self.show_terminal_type()) handler_room.room_text(ch, ">ENTER<")
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 show_char_to_char_1(victim, ch): if victim.can_see(ch): handler_game.act("$n looks at you.", ch, None, victim, merc.TO_VICT) handler_game.act("$n looks at $N.", ch, None, victim, merc.TO_NOTVICT) if not ch.is_npc() and victim.head.is_set(merc.LOST_HEAD): handler_game.act("$N is lying here.", ch, None, victim, merc.TO_CHAR) return if victim.description: ch.send(victim.description + "\n") else: handler_game.act("You see nothing special about $M.", ch, None, victim, merc.TO_CHAR) if victim.max_hit > 0: percent = (100 * victim.hit) // victim.max_hit else: percent = -1 buf = victim.pers(ch) if percent >= 100: buf += " is in perfect health.\n" elif percent >= 90: buf += " is slightly scratched.\n" elif percent >= 80: buf += " has a few bruises.\n" elif percent >= 70: buf += " has some cuts.\n" elif percent >= 60: buf += " has several wounds.\n" elif percent >= 50: buf += " has many nasty wounds.\n" elif percent >= 40: buf += " is bleeding freely.\n" elif percent >= 30: buf += " is covered in blood.\n" elif percent >= 20: buf += " is leaking guts.\n" elif percent >= 10: buf += " is almost dead.\n" else: buf += " is DYING.\n" buf = buf[0].upper() + buf[1:] ch.send(buf) if not victim.is_npc(): if victim.is_affected(merc.AFF_INFRARED) or victim.vampaff.is_set( merc.VAM_NIGHTSIGHT): handler_game.act("$N's eyes are glowing bright red.", ch, None, victim, merc.TO_CHAR) if victim.is_affected(merc.AFF_FLYING): handler_game.act("$N is hovering in the air.", ch, None, victim, merc.TO_CHAR) if victim.vampaff.is_set(merc.VAM_FANGS): handler_game.act("$N has a pair of long, pointed fangs.", ch, None, victim, merc.TO_CHAR) if victim.is_vampire() and victim.vampaff.is_set(merc.VAM_CLAWS): handler_game.act( "$N has razer sharp claws protruding from under $S finger nails.", ch, None, victim, merc.TO_CHAR) elif victim.vampaff.is_set(merc.VAM_CLAWS): handler_game.act( "$N has razer sharp talons extending from $S fingers.", ch, None, victim, merc.TO_CHAR) if victim.is_demon() or victim.special.is_set(merc.SPC_CHAMPION): if victim.demaff.is_set(merc.DEM_HORNS): handler_game.act( "$N has a pair of pointed horns extending from $S head.", ch, None, victim, merc.TO_CHAR) if victim.demaff.is_set(merc.DEM_WINGS): if victim.demaff.is_set(merc.DEM_UNFOLDED): handler_game.act( "$N has a pair of batlike wings spread out from behind $S back.", ch, None, victim, merc.TO_CHAR) else: handler_game.act( "$N has a pair of batlike wings folded behind $S back.", ch, None, victim, merc.TO_CHAR) found = False for location, instance_id in victim.equipped.items(): if not instance_id: continue item = instance.items[instance_id] if item and ch.can_see_item(item): if not found: handler_game.act("\n$N is using:", ch, None, victim, merc.TO_CHAR) found = True ch.send(merc.eq_slot_strings[location]) if ch.is_npc() or not ch.chobj or ch.chobj != item: ch.send( handler_item.format_item_to_char(item, ch, True) + "\n") else: ch.send("you\n") if victim != ch and not ch.is_npc() and not victim.head.is_set( merc.LOST_HEAD ) and game_utils.number_percent() < ch.learned["peek"]: ch.send("\nYou peek at the inventory:\n") show_list_to_char(victim.inventory, ch, True, True)
def cmd_stake(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return if not arg: ch.send("Stake whom?\n") return stake = ch.get_eq("right_hand") if not stake or stake.item_type != merc.ITEM_STAKE: stake = ch.get_eq("left_hand") if not stake or stake.item_type != merc.ITEM_STAKE: ch.send( "How can you stake someone down without holding a stake?\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if victim.is_npc(): ch.not_npc() return if ch == victim: ch.not_self() return if not victim.is_vampire(): ch.send("You can only stake vampires.\n") return if victim.position > merc.POS_MORTAL: ch.send("You can only stake down a vampire who is mortally wounded.\n") return handler_game.act("You plunge $p into $N's heart.", ch, stake, victim, merc.TO_CHAR) handler_game.act("$n plunges $p into $N's heart.", ch, stake, victim, merc.TO_NOTVICT) victim.send("You feel a stake plunged through your heart.\n") if victim.immune.is_set(merc.IMM_STAKE): return # Have to make sure they have enough blood to change back blood = victim.blood victim.blood = 666 # To take care of vampires who have powers in affect. if victim.vampaff.is_set(merc.VAM_DISGUISED): victim.cmd_mask("self") if victim.immune.is_set(merc.IMM_SHIELDED): victim.cmd_shield("") if victim.is_affected(merc.AFF_SHADOWPLANE): victim.cmd_shadowplane("") if victim.vampaff.is_set(merc.VAM_FANGS): victim.cmd_fangs("") if victim.vampaff.is_set(merc.VAM_CLAWS): victim.cmd_claws("") if victim.vampaff.is_set(merc.VAM_NIGHTSIGHT): victim.cmd_nightsight("") if victim.is_affected(merc.AFF_SHADOWSIGHT): victim.cmd_shadowsight("") if victim.act.is_set(merc.PLR_HOLYLIGHT): victim.cmd_truesight("") if victim.vampaff.is_set(merc.VAM_CHANGED): victim.cmd_change("human") if victim.polyaff.is_set(merc.POLY_SERPENT): victim.cmd_serpent("") victim.powers[merc.UNI_RAGE] = 0 victim.blood = blood victim.ch_class = state_checks.prefix_lookup(const.class_table, "human") ch.get(stake) victim.put(stake) ch.exp += 1000 victim.home = merc.ROOM_VNUM_TEMPLE
def show_char_to_char_0(victim, ch): if not victim.is_npc() and victim.chobj: return mount = victim.mount if mount and victim.mounted == merc.IS_MOUNT: return buf = [] if victim.head.is_set(merc.LOST_HEAD) and victim.is_affected( merc.AFF_POLYMORPH): buf += " " else: if not victim.is_npc() and not victim.desc: buf += "(Link-Dead) " if victim.is_affected(merc.AFF_INVISIBLE): buf += "(Invis) " if victim.is_affected(merc.AFF_HIDE): buf += "(Hide) " if victim.is_affected(merc.AFF_CHARM): buf += "(Charmed) " if victim.is_affected(merc.AFF_PASS_DOOR) or victim.is_affected( merc.AFF_ETHEREAL): buf += "(Translucent) " if victim.is_affected(merc.AFF_FAERIE_FIRE): buf += "(Pink Aura) " if victim.is_evil() and ch.is_affected(merc.AFF_DETECT_EVIL): buf += "(Red Aura) " if victim.is_affected(merc.AFF_SANCTUARY): buf += "(White Aura) " if ch.is_affected(merc.AFF_SHADOWPLANE) and not victim.is_affected( merc.AFF_SHADOWPLANE): buf += "(Normal plane) " elif not ch.is_affected(merc.AFF_SHADOWPLANE) and victim.is_affected( merc.AFF_SHADOWPLANE): buf += "(Shadowplane) " # Vampires and werewolves can recognise each other - KaVir if victim.is_hero() and ch.is_hero() and not ch.is_human(): if victim.is_vampire(): buf += "(Vampire) " elif victim.is_werewolf(): buf += "(Werewolf) " elif victim.is_demon(): if victim.special.is_set(merc.SPC_DEMON_LORD): buf += "(Demon Lord) " elif victim.special.is_set(merc.SPC_SIRE) or victim.special.is_set( merc.SPC_PRINCE): buf += "(Demon) " else: buf += "(Champion) " elif victim.is_highlander(): buf += "(Highlander) " elif victim.is_mage(): if victim.level == merc.LEVEL_APPRENTICE: buf += "(Apprentice) " elif victim.level == merc.LEVEL_MAGE: buf += "(Mage) " elif victim.level == merc.LEVEL_ARCHMAGE: buf += "(Archmage) " if not ch.is_npc() and ch.vampaff.is_set(merc.VAM_AUSPEX) and not victim.is_npc() and victim.is_vampire() and \ victim.vampaff.is_set(merc.VAM_DISGUISED): buf += "({}) ".format(victim.name) buf2 = "" vname = victim.short_descr if victim.is_npc( ) else victim.morph if victim.is_affected( merc.AFF_POLYMORPH) else victim.short_descr if victim.is_affected(merc.AFF_FLAMING): buf2 += "\n...{} is engulfed in blazing flames!".format(vname) if not victim.is_npc() and victim.head.is_set( merc.LOST_HEAD) and victim.is_affected(merc.AFF_POLYMORPH): if victim.extra.is_set(merc.EXTRA_GAGGED) and victim.extra.is_set( merc.EXTRA_BLINDFOLDED): buf2 += "\n...{} is gagged and blindfolded!".format(victim.morph) elif victim.extra.is_set(merc.EXTRA_GAGGED): buf2 += "\n...{} is gagged!".format(victim.morph) elif victim.extra.is_set(merc.EXTRA_BLINDFOLDED): buf2 += "\n...{} is blindfolded!".format(victim.morph) if victim.head.is_set(merc.LOST_HEAD) and victim.is_affected( merc.AFF_POLYMORPH): buf += "{} is lying here.".format(victim.morph[0].upper() + victim.morph[1:]) buf += buf2 + "\n" ch.send("".join(buf)) return if victim.extra.is_set(merc.EXTRA_TIED_UP): buf2 += "\n...{} is tied up".format(vname) if victim.extra.is_set(merc.EXTRA_GAGGED) and victim.extra.is_set( merc.EXTRA_BLINDFOLDED): buf2 += ", gagged and blindfolded!" elif victim.extra.is_set(merc.EXTRA_GAGGED): buf2 += " and gagged!" elif victim.extra.is_set(merc.EXTRA_BLINDFOLDED): buf2 += " and blindfolded!" else: buf2 += "!" if victim.is_affected(merc.AFF_WEBBED): buf2 += "\n...{} is coated in a sticky web.".format(vname) if not victim.is_npc() and victim.is_affected(merc.AFF_POLYMORPH): buf += victim.morph else: mount = victim.mount if victim.position == merc.POS_STANDING and victim.long_descr and not mount: ch.send("".join(buf) + victim.long_descr) if ch.is_npc() or not ch.act.is_set(merc.PLR_BRIEF): if victim.itemaff.is_set(merc.ITEMA_SHOCKSHIELD): handler_game.act( "...$N is surrounded by a crackling shield of lightning.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_FIRESHIELD): handler_game.act( "...$N is surrounded by a burning shield of fire.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_ICESHIELD): handler_game.act( "...$N is surrounded by a shimmering shield of ice.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_ACIDSHIELD): handler_game.act( "...$N is surrounded by a bubbling shield of acid.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_CHAOSSHIELD): handler_game.act( "...$N is surrounded by a swirling shield of chaos.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_REFLECT): handler_game.act( "...$N is surrounded by a flickering shield of darkness.", ch, None, victim, merc.TO_CHAR) return else: buf += victim.pers(ch) mount = victim.mounted if mount and victim.mounted == merc.IS_RIDING: buf += " is here riding {}".format( mount.short_descr if mount.is_npc() else mount.name) if victim.position == merc.POS_FIGHTING: buf += ", fighting " if not victim.fighting: buf += "thin air??" elif victim.fighting == ch: buf += "YOU!" elif victim.in_room == victim.fighting.in_room: buf += victim.fighting.pers(ch) + "." else: buf += "somone who left??" else: buf += "." elif victim.position == merc.POS_STANDING and ( victim.is_affected(merc.AFF_FLYING) or (not victim.is_npc() and victim.vampaff.is_set(merc.VAM_FLYING))): buf += " is hovering here" else: pos = victim.position if pos == merc.POS_DEAD: buf += " is DEAD!!" elif pos == merc.POS_MORTAL: buf += " is mortally wounded." elif pos == merc.POS_INCAP: buf += " is incapacitated." elif pos == merc.POS_STUNNED: buf += " is lying here stunned." elif pos == merc.POS_SLEEPING: buf += " is sleeping here." elif pos == merc.POS_RESTING: buf += " is resting here." elif pos == merc.POS_MEDITATING: buf += " is meditating here." elif pos == merc.POS_SITTING: buf += " is sitting here." elif pos == merc.POS_STANDING: if not victim.is_npc(): stance_list = [(merc.STANCE_VIPER, "viper"), (merc.STANCE_CRANE, "crane"), (merc.STANCE_CRAB, "crab"), (merc.STANCE_MONGOOSE, "mongoose"), (merc.STANCE_BULL, "bull"), (merc.STANCE_MANTIS, "mantis"), (merc.STANCE_DRAGON, "dragon"), (merc.STANCE_TIGER, "tiger"), (merc.STANCE_MONKEY, "monkey"), (merc.STANCE_SWALLOW, "swallow")] for (aa, bb) in stance_list: if victim.stance[0] == aa: buf += " is here, crouched in a {} fighting stance.".format( bb) break else: buf += " is here, crouched in a fighting stance." else: buf += " is here." elif pos == merc.POS_FIGHTING: buf += " is here, fighting " if not victim.fighting: buf += "thin air??" elif victim.fighting == ch: buf += "YOU!" elif victim.in_room == victim.fighting.in_room: buf += victim.fighting.pers(ch) + "." else: buf += "somone who left??" ch.send("".join(buf) + buf2 + "\n") if ch.is_npc() or not ch.act.is_set(merc.PLR_BRIEF): if victim.itemaff.is_set(merc.ITEMA_SHOCKSHIELD): handler_game.act( "...$N is surrounded by a crackling shield of lightning.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_FIRESHIELD): handler_game.act( "...$N is surrounded by a burning shield of fire.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_ICESHIELD): handler_game.act( "...$N is surrounded by a shimmering shield of ice.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_ACIDSHIELD): handler_game.act( "...$N is surrounded by a bubbling shield of acid.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_CHAOSSHIELD): handler_game.act( "...$N is surrounded by a swirling shield of chaos.", ch, None, victim, merc.TO_CHAR) if victim.itemaff.is_set(merc.ITEMA_REFLECT): handler_game.act( "...$N is surrounded by a flickering shield of darkness.", ch, None, victim, merc.TO_CHAR)
def move_char(ch, door): if door not in range(merc.MAX_DIR): comm.notify("move_char: bad door {}".format(door), merc.CONSOLE_ERROR) return in_room = ch.in_room if not ch._room_vnum: ch._room_vnum = in_room.vnum pexit = in_room.exit[door] to_room = pexit.to_room if pexit else None if not pexit or not to_room: ch.send("Alas, you cannot go that way.\n") return to_room = instance.rooms[pexit.to_room] if pexit.exit_info.is_set(merc.EX_CLOSED) and not ch.is_affected(merc.AFF_PASS_DOOR) and not ch.is_affected(merc.AFF_ETHEREAL) and \ not ch.is_affected(merc.AFF_SHADOWPLANE): if not ch.is_npc() and ch.is_werewolf( ) and ch.powers[merc.WPOWER_BOAR] > 0: handler_game.act("You smash open the $d.", ch, None, pexit.keyword, merc.TO_CHAR) handler_game.act("$n smashes open the $d.", ch, None, pexit.keyword, merc.TO_ROOM) pexit.exit_info.rem_bit(merc.EX_CLOSED) else: handler_game.act("The $d is closed.", ch, None, pexit.keyword, merc.TO_CHAR) return if ch.is_affected( merc.AFF_CHARM) and ch.master and in_room == instance.characters[ ch.master].in_room: ch.send("What? And leave your beloved master?\n") return mount = ch.mount if ch.is_npc() and mount and ch.mounted == merc.IS_MOUNT: ch.send("You better wait for instructions from your rider.\n") return if to_room.is_private(): if ch.is_npc() or ch.trust < merc.MAX_LEVEL: ch.send("That room is private right now.\n") return else: ch.send("That room is private (Access granted).\n") if (ch.leg_left.is_set(merc.BROKEN_LEG) or ch.leg_left.is_set(merc.LOST_LEG)) and (ch.leg_right.is_set(merc.BROKEN_LEG) or ch.leg_right.is_set(merc.LOST_LEG)) and \ (ch.arm_left.is_set(merc.BROKEN_ARM) or ch.arm_left.is_set(merc.LOST_ARM) or ch.get_eq("left_hand")) and \ (ch.arm_right.is_set(merc.BROKEN_ARM) or ch.arm_right.is_set(merc.LOST_ARM) or ch.get_eq("right_hand")): ch.send("You need at least one free arm to drag yourself with.\n") return elif ch.body.is_set(merc.BROKEN_SPINE) and ( ch.arm_left.is_set(merc.BROKEN_ARM) or ch.arm_left.is_set(merc.LOST_ARM) or ch.get_eq("left_hand")) and (ch.arm_right.is_set( merc.BROKEN_ARM) or ch.arm_right.is_set(merc.LOST_ARM) or ch.get_eq("right_hand")): ch.send("You cannot move with a broken spine.\n") return if not ch.is_npc(): mount = ch.mount if in_room.sector_type == merc.SECT_AIR or to_room.sector_type == merc.SECT_AIR: if not ch.is_affected(merc.AFF_FLYING) and (not ch.is_npc() and not ch.vampaff.is_set(merc.VAM_FLYING) and not ch.demaff.is_set(merc.DEM_UNFOLDED)) and \ (not mount or (ch.mounted == merc.IS_RIDING and not mount.is_affected(merc.AFF_FLYING))): ch.send("You can't fly.\n") return if in_room.sector_type == merc.SECT_WATER_NOSWIM or to_room.sector_type == merc.SECT_WATER_NOSWIM: # Look for a boat. found = False if not ch.is_npc() and ch.is_vampire(): if ch.vampaff.is_set(merc.VAM_FLYING): found = True elif ch.polyaff.is_set(merc.POLY_SERPENT): found = True elif ch.is_affected(merc.AFF_SHADOWPLANE): found = True else: mount = ch.mount if mount and ch.mounted == merc.IS_RIDING and mount.is_affected( merc.AFF_FLYING): found = True else: ch.send("You are unable to cross running water.\n") return if ch.is_affected(merc.AFF_FLYING) or ( not ch.is_npc() and ch.demaff.is_set(merc.DEM_UNFOLDED)): found = True if not found: boats = [ item_id for item_id in ch.inventory if instance.items[item_id].item_type == merc.ITEM_BOAT ] if not boats and not ch.is_immortal(): ch.send("You need a boat to go there.\n") return elif not ch.is_affected(merc.AFF_FLYING) and ch.polyaff.is_set( merc.POLY_FISH): from_ok = in_room.sector_type in [ merc.SECT_WATER_NOSWIM, merc.SECT_WATER_SWIM ] to_ok = to_room.sector_type in [ merc.SECT_WATER_NOSWIM, merc.SECT_WATER_SWIM ] if not from_ok or not to_ok: ch.send("You cannot cross land.\n") return move = merc.movement_loss[min( merc.SECT_MAX - 1, in_room.sector_type)] + merc.movement_loss[min( merc.SECT_MAX - 1, to_room.sector_type)] if ch.is_hero(): move = 0 if ch.mounted != merc.IS_RIDING: if ch.move < move or ch.move < 1: ch.send("You are too exhausted.\n") return ch.move -= move ch.wait_state(1) # Check for mount message - KaVir mount = ch.mount if mount and ch.mounted == merc.IS_RIDING: mount2 = " on {}.".format( mount.short_descr if mount.is_npc() else mount.name) else: mount2 = "." if ch.head.is_set(merc.LOST_HEAD) or ch.extra.is_set(merc.EXTRA_OSWITCH): leave = "rolls" elif ch.is_affected(merc.AFF_ETHEREAL): leave = "floats" elif ch.in_room.sector_type == merc.SECT_WATER_SWIM or ch.polyaff.is_set( merc.POLY_FISH): leave = "swims" elif ch.polyaff.is_set(merc.POLY_SERPENT): leave = "slithers" elif ch.polyaff.is_set(merc.POLY_WOLF): leave = "stalks" elif ch.polyaff.is_set(merc.POLY_FROG): leave = "hops" elif not ch.is_npc() and ch.demaff.is_set(merc.DEM_UNFOLDED): leave = "flies" elif ch.body.is_set( merc.BROKEN_SPINE) or (ch.leg_left.is_set(merc.LOST_LEG) and ch.leg_right.is_set(merc.LOST_LEG)): leave = "drags $mself" elif ((ch.leg_left.is_set(merc.BROKEN_LEG) or ch.leg_left.is_set(merc.LOST_LEG) or ch.leg_left.is_set(merc.LOST_FOOT)) and (ch.leg_right.is_set(merc.BROKEN_LEG) or ch.leg_right.is_set(merc.LOST_LEG) or ch.leg_right.is_set(merc.LOST_FOOT))) or \ ch.hit < ch.max_hit // 4: leave = "crawls" elif ((ch.leg_right.is_set(merc.LOST_LEG) or ch.leg_right.is_set(merc.LOST_FOOT)) and (not ch.leg_left.is_set(merc.BROKEN_LEG) and not ch.leg_left.is_set(merc.LOST_LEG) and not ch.leg_left.is_set(merc.LOST_FOOT))) or \ ((ch.leg_left.is_set(merc.LOST_LEG) or ch.leg_left.is_set(merc.LOST_FOOT)) and (not ch.leg_right.is_set(merc.BROKEN_LEG) and not ch.leg_right.is_set(merc.LOST_LEG) and not ch.leg_right.is_set(merc.LOST_FOOT))): leave = "hops" elif ((ch.leg_left.is_set(merc.BROKEN_LEG) or ch.leg_left.is_set(merc.LOST_FOOT)) and (not ch.leg_right.is_set(merc.BROKEN_LEG) and not ch.leg_right.is_set(merc.LOST_LEG) and not ch.leg_right.is_set(merc.LOST_FOOT))) or \ ((ch.leg_right.is_set(merc.BROKEN_LEG) or ch.leg_right.is_set(merc.LOST_FOOT)) and (not ch.leg_left.is_set(merc.BROKEN_LEG) and not ch.leg_left.is_set(merc.LOST_LEG) and not ch.leg_left.is_set(merc.LOST_FOOT))) or \ ch.hit < ch.max_hit // 3: leave = "limps" elif ch.hit < ch.max_hit // 2: leave = "staggers" else: leave = "walks" if not ch.is_npc() and ch.stance[0] != -1: ch.cmd_stance("") for victim in list(instance.characters.values()): if not ch.in_room or not victim.in_room or ch == victim or ch.in_room != victim.in_room or not ch.can_see( victim): continue if not ch.is_npc() and not ch.is_affected(merc.AFF_SNEAK) and ch.is_affected(merc.AFF_POLYMORPH) and (ch.is_npc() or not ch.act.is_set(merc.PLR_WIZINVIS) or ch.invis_level < merc.LEVEL_IMMORTAL) and \ victim.can_see(ch): mount = ch.mount if (mount and ch.mounted == merc.IS_RIDING and mount.is_affected(merc.AFF_FLYING)) or ch.is_affected(merc.AFF_FLYING) or \ (not ch.is_npc() and ch.vampaff.is_set(merc.VAM_FLYING)): poly = "{} flies $T{}".format(ch.morph, mount2) elif mount and ch.mounted == merc.IS_RIDING: poly = "{} rides $T{}".format(ch.morph, mount2) else: poly = "{} {} $T{}".format(ch.morph, leave, mount2) handler_game.act(poly, victim, None, merc.dir_name[door], merc.TO_CHAR) elif not ch.is_affected(merc.AFF_SNEAK) and (ch.is_npc() or not ch.act.is_set(merc.PLR_WIZINVIS) and ch.invis_level < merc.LEVEL_IMMORTAL) and \ victim.can_see(ch): mount = ch.mount if (mount and ch.mounted == merc.IS_RIDING and mount.is_affected(merc.AFF_FLYING)) or ch.is_affected(merc.AFF_FLYING) or \ (not ch.is_npc() and ch.vampaff.is_set(merc.VAM_FLYING)): poly = "$n flies {}{}".format(merc.dir_name[door], mount2) elif mount and ch.mounted == merc.IS_RIDING: poly = "$n rides {}{}".format(merc.dir_name[door], mount2) else: poly = "$n {} {}{}".format(leave, merc.dir_name[door], mount2) handler_game.act(poly, ch, None, victim, merc.TO_VICT) ch.in_room.get(ch) to_room.put(ch) dir_list = [(merc.DIR_NORTH, "the south"), (merc.DIR_EAST, "the west"), (merc.DIR_SOUTH, "the north"), (merc.DIR_WEST, "the east"), (merc.DIR_UP, "below")] for (aa, bb) in dir_list: if door == aa: buf = bb break else: buf = "above" for victim in list(instance.characters.values()): if not ch.in_room or not victim.in_room or ch == victim or ch.in_room != victim.in_room or not ch.can_see( victim): continue if not ch.is_npc() and not ch.is_affected(merc.AFF_SNEAK) and ch.is_affected(merc.AFF_POLYMORPH) and (ch.is_npc() or not ch.act.is_set(merc.PLR_WIZINVIS) or ch.invis_level < merc.LEVEL_IMMORTAL) and \ victim.can_see(ch): mount = ch.mount if (mount and ch.mounted == merc.IS_RIDING and mount.is_affected(merc.AFF_FLYING)) or ch.is_affected(merc.AFF_FLYING) or \ (not ch.is_npc() and ch.vampaff.is_set(merc.VAM_FLYING)): poly = "{} flies in from {}{}".format(ch.morph, buf, mount2) elif mount and ch.mounted == merc.IS_RIDING: poly = "{} rides in from {}{}".format(ch.morph, buf, mount2) else: poly = "{} {} in from {}{}".format(ch.morph, leave, buf, mount2) handler_game.act(poly, ch, None, victim, merc.TO_VICT) elif not ch.is_affected(merc.AFF_SNEAK) and (ch.is_npc() or not ch.act.is_set(merc.PLR_WIZINVIS) and ch.invis_level < merc.LEVEL_IMMORTAL) and \ victim.can_see(ch): mount = ch.mount if (mount and ch.mounted == merc.IS_RIDING and mount.is_affected(merc.AFF_FLYING)) or ch.is_affected(merc.AFF_FLYING) or \ (not ch.is_npc() and ch.vampaff.is_set(merc.VAM_FLYING)): poly = "$n flies in from {}{}".format(buf, mount2) elif mount and ch.mounted == merc.IS_RIDING: poly = "$n rides in from {}{}".format(buf, mount2) else: poly = "$n {} in from {}{}".format(leave, buf, mount2) handler_game.act(poly, ch, None, victim, merc.TO_VICT) ch.cmd_look("auto") if in_room.instance_id == to_room.instance_id: # no circular follows return for fch_id in in_room.people[:]: fch = instance.characters[fch_id] mount = fch.mount if mount and mount == ch and fch.mounted == merc.IS_MOUNT: handler_game.act("$N digs $S heels into you.", fch, None, ch, merc.TO_CHAR) fch.in_room.get(fch) ch.in_room.put(fch) if fch.master == ch.instance_id and fch.position == merc.POS_STANDING and fch.in_room != ch.in_room: handler_game.act("You follow $N.", fch, None, ch, merc.TO_CHAR) move_char(fch, door) handler_room.room_text(ch, ">ENTER<")
def cmd_activate(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not arg1: ch.send("Which item do you wish to activate?\n") return item = ch.get_item_wear(arg1) if not item: item = ch.get_item_here(arg1) if not item: ch.send("You can't find that item.\n") return # You should only be able to use nontake items on floor if item.flags.take: ch.send("But you are not wearing it!\n") return if not item.spectype.is_set(merc.SITEM_ACTIVATE): ch.send("This item cannot be activated.\n") return if item.spectype.is_set(merc.SITEM_TARGET) and not arg2: ch.send("Who do you wish to activate it on?\n") return if item.spectype.is_set(merc.SITEM_TARGET): victim = ch.get_char_room(arg2) if not victim: ch.not_here(arg2) return else: victim = ch if item.chpoweruse: handler_game.kavitem(item.chpoweruse, ch, item, None, merc.TO_CHAR) if item.victpoweruse: handler_game.kavitem(item.victpoweruse, ch, item, None, merc.TO_ROOM) if item.spectype.is_set(merc.SITEM_SPELL): castlevel = state_checks.urange(1, item.level, 60) handler_magic.obj_cast_spell(item.specpower, castlevel, ch, victim, None) ch.wait_state(merc.PULSE_VIOLENCE // 2) if item.spectype.is_set(merc.SITEM_DELAY1): ch.wait_state(merc.PULSE_VIOLENCE // 2) if item.spectype.is_set(merc.SITEM_DELAY2): ch.wait_state(merc.PULSE_VIOLENCE) return if item.spectype.is_set(merc.SITEM_TRANSPORTER): if item.chpoweron: handler_game.kavitem(item.chpoweron, ch, item, None, merc.TO_CHAR) if item.victpoweron: handler_game.kavitem(item.victpoweron, ch, item, None, merc.TO_ROOM) to_instance_id = instance.instances_by_room[item.specpower][0] proomindex = instance.rooms[to_instance_id] item.specpower = ch.in_room.vnum if not proomindex: return ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") if item.chpoweroff: handler_game.kavitem(item.chpoweroff, ch, item, None, merc.TO_CHAR) if item.victpoweroff: handler_game.kavitem(item.victpoweroff, ch, item, None, merc.TO_ROOM) if not item.flags.artifact and ch.in_room.room_flags.is_set( merc.ROOM_NO_TELEPORT) and item.flags.take: ch.send("A powerful force hurls you from the room.\n") handler_game.act("$n is hurled from the room by a powerful force.", ch, None, None, merc.TO_ROOM) ch.position = merc.POS_STUNNED ch.in_room.get(ch) room_id = instance.instances_by_room[merc.ROOM_VNUM_TEMPLE][0] instance.rooms[room_id].put(ch) handler_game.act( "$n appears in the room, and falls to the ground stunned.", ch, None, None, merc.TO_ROOM) mount = ch.mount if mount: mount.in_room.get(mount) ch.in_room.put(mount) mount.cmd_look("auto") elif item.spectype.is_set(merc.SITEM_TELEPORTER): if item.chpoweron: handler_game.kavitem(item.chpoweron, ch, item, None, merc.TO_CHAR) if item.victpoweron: handler_game.kavitem(item.victpoweron, ch, item, None, merc.TO_ROOM) proomindex = instance.rooms[item.specpower] if not proomindex: return ch.in_room.get(ch) proomindex.put(ch) ch.cmd_look("auto") if item.chpoweroff: handler_game.kavitem(item.chpoweroff, ch, item, None, merc.TO_CHAR) if item.victpoweroff: handler_game.kavitem(item.victpoweroff, ch, item, None, merc.TO_ROOM) if not item.flags.artifact and ch.in_room.room_flags.is_set( merc.ROOM_NO_TELEPORT) and item.flags.take: ch.send("A powerful force hurls you from the room.\n") handler_game.act("$n is hurled from the room by a powerful force.", ch, None, None, merc.TO_ROOM) ch.position = merc.POS_STUNNED ch.in_room.get(ch) room_id = instance.instances_by_room[merc.ROOM_VNUM_TEMPLE][0] instance.rooms[room_id].put(ch) handler_game.act( "$n appears in the room, and falls to the ground stunned.", ch, None, None, merc.TO_ROOM) mount = ch.mount if mount: mount.in_room.get(mount) ch.in_room.put(mount) mount.cmd_look("auto") elif item.spectype.is_set(merc.SITEM_OBJECT): obj_index = instance.item_templates[item.specpower] if not obj_index: return item = object_creator.create_item(obj_index, ch.level) if item.flags.take: ch.put(item) else: ch.in_room.put(item) elif item.spectype.is_set(merc.SITEM_MOBILE): mob_index = instance.npc_templates[item.specpower] if not mob_index: return npc = object_creator.create_mobile(mob_index) ch.in_room.put(npc) elif item.spectype.is_set(merc.SITEM_ACTION): ch.interpret(item.victpoweron) if item.victpoweroff: for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if ch == vch: continue vch.interpret(item.victpoweroff) continue
def cmd_drop(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Drop what?\n") return if arg.isdigit(): # 'drop NNNN coins' amount = int(arg) argument, arg = game_utils.read_word(argument) if amount <= 0 or (not game_utils.str_cmp(arg, ["coins", "coin"])): ch.send("Sorry, you can't do that.\n") return # Otherwise causes complications if there's a pile on each plane if ch.is_affected(merc.AFF_SHADOWPLANE): ch.send("You cannot drop coins in the shadowplane.\n") return if ch.gold < amount: ch.send("You haven't got that many coins.\n") return ch.gold -= amount for item_id in ch.in_room.items: item = instance.items[item_id] if item.vnum == merc.OBJ_VNUM_MONEY_ONE: amount += 1 item.extract() elif item.vnum == merc.OBJ_VNUM_MONEY_SOME: amount += item.value[0] item.extract() object_creator.create_money(amount).to_room(ch.in_room) handler_game.act("$n drops some gold.", ch, None, None, merc.TO_ROOM) ch.send("Ok.\n") ch.save(force=True) return if not game_utils.str_cmp(arg, "all") and not game_utils.str_prefix( "all.", arg): # 'drop obj' item = ch.get_item_carry(arg) if not item: ch.send("You do not have that item.\n") return if not ch.can_drop_item(item): ch.send("You can't let go of it.\n") return ch.get(item) ch.in_room.put(item) # Objects should only have a shadowplane flag when on the floor if ch.is_affected(merc.AFF_SHADOWPLANE) and not item.flags.shadowplane: item.flags.shadowplane = True handler_game.act("$n drops $p.", ch, item, None, merc.TO_ROOM) handler_game.act("You drop $p.", ch, item, None, merc.TO_CHAR) else: # 'drop all' or 'drop all.obj' found = False for item_id in ch.inventory[:]: item = instance.items[item_id] if (len(arg) == 3 or game_utils.is_name(arg[4:], item.name) ) and ch.can_see_item( item) and not item.equipped_to and ch.can_drop_item(item): found = True ch.get(item) ch.in_room.put(item) # Objects should only have a shadowplane flag when on the floor if ch.is_affected( merc.AFF_SHADOWPLANE) and not item.flags.shadowplane: item.flags.shadowplane = True handler_game.act("$n drops $p.", ch, item, None, merc.TO_ROOM) handler_game.act("You drop $p.", ch, item, None, merc.TO_CHAR) if not found: if len(arg) == 3: handler_game.act("You are not carrying anything.", ch, None, arg, merc.TO_CHAR) else: handler_game.act("You are not carrying any $T.", ch, None, arg[4:], merc.TO_CHAR)
def do_look(ch, argument): if ch.is_npc() or not ch.desc: 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 not ch.check_blind(): return room = ch.in_room if not ch.is_npc() and not ch.act.is_set(merc.PLR_HOLYLIGHT) \ and ch.in_room.is_dark(): ch.send("It is pitch black ... \n") handler_ch.show_char_to_char(room.people, ch) return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) number, arg3 = game_utils.number_argument(arg1) count = 0 if not arg1 or arg1 == "auto": # 'look' or 'look auto' ch.send(room.name) if ch.is_immortal() \ and (ch.is_npc() or (ch.act.is_set(merc.PLR_HOLYLIGHT) or ch.act.is_set(merc.PLR_OMNI))): ch.send( " Room[[{room.instance_id}]] Template[[{room.vnum}]]".format( room=room)) ch.send("\n") if not arg1 or (not ch.is_npc() and not ch.comm.is_set(merc.COMM_BRIEF)): ch.send(" %s\n" % room.description) if not ch.is_npc() \ and ch.act.is_set(merc.PLR_AUTOEXIT): ch.send("\n") ch.do_exits("auto") handler_ch.show_list_to_char(room.items, ch, False, False) handler_ch.show_char_to_char(room.people, ch) return if arg1 == "i" or arg1 == "in" or arg1 == "on": # '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 item_type = item.item_type if 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] // 4: amnt = "less than half-" elif item.value[1] < 3 * item.value[0] // 4: amnt = "abount half-" else: amnt = "more than half-" ch.send("It's %sfilled with a %s liquid.\n" % (amnt, const.liq_table[item.value[2]].color)) elif item_type == merc.ITEM_CONTAINER or item_type == merc.ITEM_CORPSE_NPC \ or item_type == 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 holds:", ch, item, None, merc.TO_CHAR) handler_ch.show_list_to_char(item.inventory, ch, True, True) return 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 item_list = ch.items item_list.extend(room.items) for obj_id in item_list: item = instance.items[obj_id] if ch.can_see_item(item): # player can see object pdesc = game_utils.get_extra_descr(arg3, item.extra_descr) if pdesc: count += 1 if count == number: ch.send(pdesc) return else: continue if game_utils.is_name(arg3, item.name.lower()): count += 1 if count == number: ch.send("%s\n" % item.description) return pdesc = game_utils.get_extra_descr(arg3, room.extra_descr) if pdesc: count += 1 if count == number: ch.send(pdesc) return if count > 0 and count != number: if count == 1: ch.send("You only see one %s here.\n" % arg3) else: ch.send("You only see %d of those here.\n" % count) return if "north".startswith(arg1): door = 0 elif "east".startswith(arg1): door = 1 elif "south".startswith(arg1): door = 2 elif "west".startswith(arg1): door = 3 elif "up".startswith(arg1): door = 4 elif "down".startswith(arg1): door = 5 else: ch.send("You do not see that here.\n") return # 'look direction' if door not in room.exit \ or not room.exit[door]: ch.send("Nothing special there.\n") return pexit = room.exit[door] if pexit.description: ch.send(pexit.description) else: ch.send("Nothing special there.\n") if pexit.keyword and pexit.keyword.strip(): 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) return