def do_brandish(ch, argument): staff = ch.get_eq('held') if not staff: ch.send("You hold nothing in your hand.\n") return if staff.item_type != merc.ITEM_STAFF: ch.send("You can brandish only with a staff.\n") return sn = staff.value[3] if not sn or not const.skill_table[sn].spell_fun: logger.error("BUG: Do_brandish: bad sn %s.", sn) return state_checks.WAIT_STATE(ch, 2 * merc.PULSE_VIOLENCE) if staff.value[2] > 0: handler_game.act("$n brandishes $p.", ch, staff, None, merc.TO_ROOM) handler_game.act("You brandish $p.", ch, staff, None, merc.TO_CHAR) if ch.level < staff.level or random.randint( 1, 99) >= 20 + ch.get_skill("staves") * 4 / 5: handler_game.act("You fail to invoke $p.", ch, staff, None, merc.TO_CHAR) handler_game.act("...and nothing happens.", ch, None, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve("staves", False, 2) else: for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] target = const.skill_table[sn].target if target == merc.TAR_IGNORE: if vch != ch: continue elif target == merc.TAR_CHAR_OFFENSIVE: if vch.is_npc() if ch.is_npc() else not vch.is_npc(): continue elif target == merc.TAR_CHAR_DEFENSIVE: if not vch.is_npc() if ch.is_npc() else vch.is_npc(): continue elif target == merc.TAR_CHAR_SELF: if vch != ch: continue else: logger.error("BUG: Do_brandish: bad target for sn %s.", sn) return handler_magic.obj_cast_spell(staff.value[3], staff.value[0], ch, vch, None) if ch.is_pc(): ch.check_improve("staves", True, 2) staff.value[2] -= 1 if staff.value[2] <= 0: handler_game.act("$n's $p blazes bright and is gone.", ch, staff, None, merc.TO_ROOM) handler_game.act("Your $p blazes bright and is gone.", ch, staff, None, merc.TO_CHAR) staff.extract()
def cmd_zap(ch, argument): argument, arg = game_utils.read_word(argument) if not arg and not ch.fighting: ch.send("Zap whom or what?\n") return wand = ch.get_eq("right_hand") if not wand or wand.item_type != merc.ITEM_WAND: wand = ch.get_eq("left_hand") if not wand or wand.item_type != merc.ITEM_WAND: ch.send("You hold nothing in your hand.\n") return item = None if not arg: if ch.fighting: victim = ch.fighting else: ch.send("Zap whom or what?\n") return else: victim = ch.get_char_room(arg) item = ch.get_item_here(arg) if not victim and not item: ch.send("You can't find it.\n") return ch.wait_state(merc.PULSE_VIOLENCE * 2) if wand.value[2] > 0: if victim: handler_game.act("$n zaps $N with $p.", ch, wand, victim, merc.TO_ROOM) handler_game.act("You zap $N with $p.", ch, wand, victim, merc.TO_CHAR) else: handler_game.act("$n zaps $P with $p.", ch, wand, item, merc.TO_ROOM) handler_game.act("You zap $P with $p.", ch, wand, item, merc.TO_CHAR) handler_magic.obj_cast_spell(wand.value[3], wand.value[0], ch, victim, item) wand.value[2] -= 1 if wand.value[2] <= 0: handler_game.act("$n's $p explodes into fragments.", ch, wand, None, merc.TO_ROOM) handler_game.act("Your $p explodes into fragments.", ch, wand, None, merc.TO_CHAR) wand.extract()
def do_zap(ch, argument): argument, arg = game_utils.read_word(argument) if not arg and not ch.fighting: ch.send("Zap whom or what?\n") return wand = ch.get_eq('held') if not wand: ch.send("You hold nothing in your hand.\n") return if wand.item_type != merc.ITEM_WAND: ch.send("You can zap only with a wand.\n") return obj = None victim = None if not arg: if ch.fighting: victim = ch.fighting else: ch.send("Zap whom or what?\n") return else: victim = ch.get_char_room(arg) obj = ch.get_item_here(arg) if not victim and not obj: ch.send("You can't find it.\n") return state_checks.WAIT_STATE(ch, 2 * merc.PULSE_VIOLENCE) if wand.value[2] > 0: if victim: handler_game.act("$n zaps $N with $p.", ch, wand, victim, merc.TO_NOTVICT) handler_game.act("You zap $N with $p.", ch, wand, victim, merc.TO_CHAR) handler_game.act("$n zaps you with $p.", ch, wand, victim, merc.TO_VICT) else: handler_game.act("$n zaps $P with $p.", ch, wand, obj, merc.TO_ROOM) handler_game.act("You zap $P with $p.", ch, wand, obj, merc.TO_CHAR) if ch.level < wand.level \ or random.randint(1, 99) >= 20 + ch.get_skill("wands") * 4 // 5: handler_game.act("Your efforts with $p produce only smoke and sparks.", ch, wand, None, merc.TO_CHAR) handler_game.act("$n's efforts with $p produce only smoke and sparks.", ch, wand, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve( "wands", False, 2) else: handler_magic.obj_cast_spell(wand.value[3], wand.value[0], ch, victim, obj) if ch.is_pc(): ch.check_improve( "wands", True, 2) wand.value[2] -= 1 if wand.value[2] <= 0: handler_game.act("$n's $p explodes into fragments.", ch, wand, None, merc.TO_ROOM) handler_game.act("Your $p explodes into fragments.", ch, wand, None, merc.TO_CHAR) wand.extract()
def do_brandish(ch, argument): staff = ch.get_eq('held') if not staff: ch.send("You hold nothing in your hand.\n") return if staff.item_type != merc.ITEM_STAFF: ch.send("You can brandish only with a staff.\n") return sn = staff.value[3] if not sn or not const.skill_table[sn].spell_fun: logger.error("BUG: Do_brandish: bad sn %s.", sn) return state_checks.WAIT_STATE(ch, 2 * merc.PULSE_VIOLENCE) if staff.value[2] > 0: handler_game.act("$n brandishes $p.", ch, staff, None, merc.TO_ROOM) handler_game.act("You brandish $p.", ch, staff, None, merc.TO_CHAR) if ch.level < staff.level or random.randint(1, 99) >= 20 + ch.get_skill("staves") * 4 / 5: handler_game.act("You fail to invoke $p.", ch, staff, None, merc.TO_CHAR) handler_game.act("...and nothing happens.", ch, None, None, merc.TO_ROOM) if ch.is_pc(): ch.check_improve("staves", False, 2) else: for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] target = const.skill_table[sn].target if target == merc.TAR_IGNORE: if vch != ch: continue elif target == merc.TAR_CHAR_OFFENSIVE: if vch.is_npc() if ch.is_npc() else not vch.is_npc(): continue elif target == merc.TAR_CHAR_DEFENSIVE: if not vch.is_npc() if ch.is_npc() else vch.is_npc(): continue elif target == merc.TAR_CHAR_SELF: if vch != ch: continue else: logger.error("BUG: Do_brandish: bad target for sn %s.", sn) return handler_magic.obj_cast_spell(staff.value[3], staff.value[0], ch, vch, None) if ch.is_pc(): ch.check_improve("staves", True, 2) staff.value[2] -= 1 if staff.value[2] <= 0: handler_game.act("$n's $p blazes bright and is gone.", ch, staff, None, merc.TO_ROOM) handler_game.act("Your $p blazes bright and is gone.", ch, staff, None, merc.TO_CHAR) staff.extract()
def cmd_brandish(ch, argument): staff = ch.get_eq("right_hand") if not staff or staff.item_type != merc.ITEM_STAFF: staff = ch.get_eq("left_hand") if not staff or staff.item_type != merc.ITEM_STAFF: ch.send("You hold nothing in your hand.\n") return sn = staff.value[3] if not sn or not const.skill_table[sn].spell_fun: comm.notify("cmd_brandish: bad sn {}".format(sn), merc.CONSOLE_ERROR) return ch.wait_state(merc.PULSE_VIOLENCE * 2) if staff.value[2] > 0: handler_game.act("$n brandishes $p.", ch, staff, None, merc.TO_ROOM) handler_game.act("You brandish $p.", ch, staff, None, merc.TO_CHAR) for vch in ch.in_room.people[:]: target = const.skill_table[sn].target if target in [merc.TAR_IGNORE, merc.TAR_CHAR_SELF]: if vch != ch: continue elif target == merc.TAR_CHAR_OFFENSIVE: if vch.is_npc() if ch.is_npc() else not vch.is_npc(): continue elif target == merc.TAR_CHAR_DEFENSIVE: if not vch.is_npc() if ch.is_npc() else vch.is_npc(): continue else: comm.notify("cmd_brandish: bad target for sn {}".format(sn), merc.CONSOLE_ERROR) return handler_magic.obj_cast_spell(staff.value[3], staff.value[0], ch, vch, None) staff.value[2] -= 1 if staff.value[2] <= 0: handler_game.act("$n's $p blazes bright and is gone.", ch, staff, None, merc.TO_ROOM) handler_game.act("Your $p blazes bright and is gone.", ch, staff, None, merc.TO_CHAR) staff.extract()
def cmd_quaff(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Quaff what?\n") return item = ch.get_item_carry(arg) if not item: ch.send("You do not have that potion.\n") return if item.item_type != merc.ITEM_POTION: ch.send("You can quaff only potions.\n") return handler_game.act("$n quaffs $p.", ch, item, None, merc.TO_ROOM) handler_game.act("You quaff $p.", ch, item, None, merc.TO_CHAR) handler_magic.obj_cast_spell(item.value[1], item.value[0], ch, ch, None) handler_magic.obj_cast_spell(item.value[2], item.value[0], ch, ch, None) handler_magic.obj_cast_spell(item.value[3], item.value[0], ch, ch, None) item.extract() if ch.position == merc.POS_FIGHTING: ch.wait_state(merc.PULSE_VIOLENCE // 2)
def cmd_eat(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Eat what?\n") return item = ch.get_item_carry(arg) if not item: ch.send("You do not have that item.\n") return if not ch.is_immortal(): if not ch.is_npc() and ch.is_vampire( ) and item.item_type == merc.ITEM_FOOD: ch.send("You are unable to stomach it.\n") return if item.item_type not in [ merc.ITEM_FOOD, merc.ITEM_PILL, merc.ITEM_EGG, merc.ITEM_QUEST ]: if ch.is_npc() or not ch.special.is_set( merc.SPC_WOLFMAN) or item.item_type != merc.ITEM_TRASH: ch.send("That's not edible.\n") return handler_game.act("$n eats $p.", ch, item, None, merc.TO_ROOM) handler_game.act("You eat $p.", ch, item, None, merc.TO_CHAR) itype = item.item_type if itype in [merc.ITEM_FOOD, merc.ITEM_EGG]: if item.value[3] != 0: # The shit was poisoned! handler_game.act("$n chokes and gags.", ch, None, None, merc.TO_ROOM) ch.send("You choke and gag.\n") aff = handler_game.AffectData(type="poison", duration=item.value[0] * 2, locattion=merc.APPLY_NONE, bitvector=merc.AFF_POISON) ch.affect_join(aff) elif itype == merc.ITEM_PILL: handler_magic.obj_cast_spell(item.value[1], item.value[0], ch, ch, None) handler_magic.obj_cast_spell(item.value[2], item.value[0], ch, ch, None) handler_magic.obj_cast_spell(item.value[3], item.value[0], ch, ch, None) if ch.position == merc.POS_FIGHTING: ch.wait_state(merc.PULSE_VIOLENCE // 2) elif itype == merc.ITEM_QUEST: if not ch.is_npc(): ch.quest += item.value[0] item.extract()
def do_eat(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Eat what?\n") return obj = ch.get_item_carry(arg, ch) if not obj: ch.send("You do not have that item.\n") return if not ch.is_immortal(): if obj.item_type != merc.ITEM_FOOD and obj.item_type != merc.ITEM_PILL: ch.send("That's not edible.\n") return if not ch.is_npc() and ch.condition[merc.COND_FULL] > 40: ch.send("You are too full to eat more.\n") return handler_game.act("$n eats $p.", ch, obj, None, merc.TO_ROOM) handler_game.act("You eat $p.", ch, obj, None, merc.TO_CHAR) if obj.item_type == merc.ITEM_FOOD: if not ch.is_npc(): condition = ch.condition[merc.COND_HUNGER] update.gain_condition(ch, merc.COND_FULL, obj.value[0]) update.gain_condition(ch, merc.COND_HUNGER, obj.value[1]) if condition == 0 and ch.condition[merc.COND_HUNGER] > 0: ch.send("You are no longer hungry.\n") elif ch.condition[merc.COND_FULL] > 40: ch.send("You are full.\n") if obj.value[3] != 0: # The food was poisoned! af = handler_game.AFFECT_DATA() handler_game.act("$n chokes and gags.", ch, 0, 0, merc.TO_ROOM) ch.send("You choke and gag.\n") af.where = merc.TO_AFFECTS af.type = "poison" af.level = game_utils.number_fuzzy(obj.value[0]) af.duration = 2 * obj.value[0] af.location = merc.APPLY_NONE af.modifier = 0 af.bitvector = merc.AFF_POISON ch.affect_join(af) elif obj.item_type == merc.ITEM_PILL: handler_magic.obj_cast_spell(obj.value[1], obj.value[0], ch, ch, None) handler_magic.obj_cast_spell(obj.value[2], obj.value[0], ch, ch, None) handler_magic.obj_cast_spell(obj.value[3], obj.value[0], ch, ch, None) obj.extract() return
def do_recite(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) scroll = ch.get_item_carry(arg1, ch) if not scroll: ch.send("You do not have that scroll.\n") return if scroll.item_type != merc.ITEM_SCROLL: ch.send("You can recite only scrolls.\n") return if ch.level < scroll.level: ch.send("This scroll is too complex for you to comprehend.\n") return obj = None victim = None if not arg2: victim = ch else: victim = ch.get_char_room(arg2) obj = ch.get_item_here(arg2) if not victim and not obj: ch.send("You can't find it.\n") return handler_game.act("$n recites $p.", ch, scroll, None, merc.TO_ROOM) handler_game.act("You recite $p.", ch, scroll, None, merc.TO_CHAR) if random.randint(1, 99) >= 20 + ch.get_skill("scrolls") * 4 // 5: ch.send("You mispronounce a syllable.\n") if ch.is_pc(): ch.check_improve("scrolls", False, 2) else: handler_magic.obj_cast_spell(scroll.value[1], scroll.value[0], ch, victim, obj) handler_magic.obj_cast_spell(scroll.value[2], scroll.value[0], ch, victim, obj) handler_magic.obj_cast_spell(scroll.value[3], scroll.value[0], ch, victim, obj) if ch.is_pc(): ch.check_improve("scrolls", True, 2) scroll.extract() return
def do_recite(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) scroll = ch.get_item_carry(arg1, ch) if not scroll: ch.send("You do not have that scroll.\n") return if scroll.item_type != merc.ITEM_SCROLL: ch.send("You can recite only scrolls.\n") return if ch.level < scroll.level: ch.send("This scroll is too complex for you to comprehend.\n") return obj = None victim = None if not arg2: victim = ch else: victim = ch.get_char_room(arg2) obj = ch.get_item_here(arg2) if not victim and not obj: ch.send("You can't find it.\n") return handler_game.act("$n recites $p.", ch, scroll, None, merc.TO_ROOM) handler_game.act("You recite $p.", ch, scroll, None, merc.TO_CHAR) if random.randint(1, 99) >= 20 + ch.get_skill("scrolls") * 4 // 5: ch.send("You mispronounce a syllable.\n") if ch.is_pc(): ch.check_improve( "scrolls", False, 2) else: handler_magic.obj_cast_spell(scroll.value[1], scroll.value[0], ch, victim, obj) handler_magic.obj_cast_spell(scroll.value[2], scroll.value[0], ch, victim, obj) handler_magic.obj_cast_spell(scroll.value[3], scroll.value[0], ch, victim, obj) if ch.is_pc(): ch.check_improve( "scrolls", True, 2) scroll.extract() return
def cmd_recite(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) scroll = ch.get_item_carry(arg1) if not scroll: ch.send("You do not have that scroll.\n") return if scroll.item_type != merc.ITEM_SCROLL: ch.send("You can recite only scrolls.\n") return item = None if not arg2: victim = ch else: victim = ch.get_char_room(arg2) item = ch.get_item_here(arg2) if not victim and not item: ch.send("You can't find it.\n") return handler_game.act("$n recites $p.", ch, scroll, None, merc.TO_ROOM) handler_game.act("You recite $p.", ch, scroll, None, merc.TO_CHAR) handler_magic.obj_cast_spell(scroll.value[1], item.value[0], ch, victim, item) handler_magic.obj_cast_spell(scroll.value[2], item.value[0], ch, victim, item) handler_magic.obj_cast_spell(scroll.value[3], item.value[0], ch, victim, item) scroll.extract() if ch.position == merc.POS_FIGHTING: ch.wait_state(merc.PULSE_VIOLENCE // 2)
def do_quaff(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Quaff what?\n") return obj = ch.get_item_carry(arg, ch) if not obj: ch.send("You do not have that potion.\n") return if obj.item_type != merc.ITEM_POTION: ch.send("You can quaff only potions.\n") return if ch.level < obj.level: ch.send("This liquid is too powerful for you to drink.\n") return handler_game.act("$n quaffs $p.", ch, obj, None, merc.TO_ROOM) handler_game.act("You quaff $p.", ch, obj, None, merc.TO_CHAR) handler_magic.obj_cast_spell(obj.value[1], obj.value[0], ch, ch, None) handler_magic.obj_cast_spell(obj.value[2], obj.value[0], ch, ch, None) handler_magic.obj_cast_spell(obj.value[3], obj.value[0], ch, ch, None) obj.extract() return
def cmd_press(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 press?\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_PRESS): ch.send("There is nothing on this item to press.\n") return if item.spectype.is_set(merc.SITEM_TARGET) and not arg2: ch.send("Who do you wish to use 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) proomindex = instance.rooms[item.specpower] 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