def enhance_stat(self, level, victim, apply_bit, bonuses, affect_bit): if victim.itemaff.is_set(merc.ITEMA_REFLECT): # noinspection PyUnresolvedReferences self.send("You are unable to focus your spell.\n") return if state_checks.is_set(affect_bit, merc.AFF_WEBBED) and victim.is_affected( merc.AFF_WEBBED): state_checks.remove_bit(affect_bit, merc.AFF_WEBBED) elif state_checks.is_set( affect_bit, merc.AFF_WEBBED) and fight.is_safe(self, victim): state_checks.remove_bit(affect_bit, merc.AFF_WEBBED) if state_checks.is_set( affect_bit, merc.AFF_CHARM) and not victim.is_affected.is_set( merc.AFF_CHARM): if victim.level <= 50 and ( victim.is_npc() or not victim.immune.is_set(merc.IMM_CHARM)): if victim.master: victim.stop_follower() victim.add_follower(self) else: # noinspection PyUnresolvedReferences self.send("The spell failed.\n") return aff = handler_game.AffectData(type="reserved", duration=level, location=apply_bit, modifier=bonuses, bitvector=affect_bit) victim.affect_join(aff)
def 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_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 spl_web(sn, level, ch, victim, target): handler_game.act( "You point your finger at $N and a web flies from your hand!", ch, None, victim, merc.TO_CHAR) handler_game.act("$n points $s finger at $N and a web flies from $s hand!", ch, None, victim, merc.TO_NOTVICT) handler_game.act( "$n points $s finger at you and a web flies from $s hand!", ch, None, victim, merc.TO_VICT) if victim.is_affected(merc.AFF_WEBBED): ch.send("But they are already webbed!\n") return if fight.is_safe(ch, victim): return if handler_magic.saves_spell( level, victim) and victim.position >= merc.POS_FIGHTING: victim.send("You dodge the web!\n") handler_game.act("$n dodges the web!", victim, None, None, merc.TO_ROOM) return aff = handler_game.AffectData(type=sn, location=merc.APPLY_AC, modifier=200, duration=game_utils.number_range(1, 2), bitvector=merc.AFF_WEBBED) victim.affect_join(aff) victim.send("You are coated in a sticky web!\n") handler_game.act("$n is coated in a sticky web!", victim, None, None, merc.TO_ROOM)
def do_consider(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Consider killing whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.send("They're not here.\n") return if fight.is_safe(ch, victim): ch.send("Don't even think about it.\n") return diff = victim.level - ch.level if diff <= -10: msg = "You can kill $N naked and weaponless." elif diff <= -5: msg = "$N is no match for you." elif diff <= -2: msg = "$N looks like an easy kill." elif diff <= 1: msg = "The perfect match!" elif diff <= 4: msg = "$N says 'Do you feel lucky, punk?'." elif diff <= 9: msg = "$N laughs at you mercilessly." else: msg = "Death will thank you for your gift." handler_game.act(msg, ch, None, victim, merc.TO_CHAR) return
def cmd_rescue(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Rescue whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if victim == ch: ch.send("What about fleeing instead?\n") return if not ch.is_npc() and victim.is_npc(): ch.send("Doesn't need your help!\n") return if ch.fighting == victim: ch.send("Too late.\n") return fch = victim.fighting if not fch: ch.send("That person is not fighting right now.\n") return if fight.is_safe(ch, fch) or fight.is_safe(ch, victim): return ch.wait_state(const.skill_table["rescue"].beats) if not ch.is_npc() and game_utils.number_percent() > ch.learned["rescue"]: ch.send("You fail the rescue.\n") return handler_game.act("You rescue $N!", ch, None, victim, merc.TO_CHAR) handler_game.act("$n rescues you!", ch, None, victim, merc.TO_VICT) handler_game.act("$n rescues $N!", ch, None, victim, merc.TO_NOTVICT) fight.stop_fighting(fch, False) fight.stop_fighting(victim, False) fight.check_killer(ch, fch) fight.set_fighting(ch, fch) fight.set_fighting(fch, ch)
def cmd_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 not victim: ch.not_here(arg) return if victim == ch: ch.send("You cannot kill yourself.\n") return if fight.is_safe(ch, victim): return if ch.is_affected( merc.AFF_CHARM) and instance.characters[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 ch.wait_state(merc.PULSE_VIOLENCE) fight.check_killer(ch, victim) if not ch.is_npc() and ch.is_werewolf() and game_utils.number_range(1, 3) == 1 and \ ch.powers[merc.WPOWER_BOAR] > 1 and victim.position == merc.POS_STANDING: handler_game.act("You charge into $N, knocking $M from $S feet.", ch, None, victim, merc.TO_CHAR) handler_game.act("$n charge into $N, knocking $M from $S feet.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n charge into you, knocking you from your feet.", ch, None, victim, merc.TO_VICT) victim.position = merc.POS_STUNNED fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) return fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
def cmd_backstab(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Backstab whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if victim == ch: ch.not_self() return if fight.is_safe(ch, victim): return item = ch.get_eq("right_hand") if not item or item.value[3] != 11: item = ch.get_eq("left_hand") if not item or item.value[3] != 11: ch.send("You need to wield a piercing weapon.\n") return if victim.fighting: ch.send("You can't backstab a fighting person.\n") return if victim.hit < victim.max_hit: handler_game.act("$N is hurt and suspicious ... you can't sneak up.", ch, None, victim, merc.TO_CHAR) return fight.check_killer(ch, victim) ch.wait_state(const.skill_table["backstab"].beats) if not victim.is_npc() and victim.immune.is_set(merc.IMM_BACKSTAB): fight.damage(ch, victim, 0, "backstab") elif not victim.is_npc() or ch.is_npc( ) or game_utils.number_percent() < ch.learned["backstab"]: fight.multi_hit(ch, victim, "backstab") else: fight.damage(ch, victim, 0, "backstab")
def do_backstab(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Backstab whom?\n") return victim = None if ch.fighting: ch.send("You're facing the wrong end.\n") return else: victim = ch.get_char_room(arg) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("How can you sneak up on yourself?\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.fighting and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n") return item = ch.get_eq('main_hand') if not item: ch.send("You need to wield a weapon to backstab.\n") return if victim.hit < victim.max_hit // 3: handler_game.act("$N is hurt and suspicious ... you can't sneak up.", ch, None, victim, merc.TO_CHAR) return fight.check_killer(ch, victim) state_checks.WAIT_STATE(ch, const.skill_table['backstab'].beats ) if random.randint(1, 99) < ch.get_skill('backstab') \ or (ch.get_skill('backstab') >= 2 and not state_checks.IS_AWAKE(victim)): if ch.is_pc(): ch.check_improve('backstab',True,1) fight.multi_hit(ch, victim, 'backstab') else: if ch.is_pc(): ch.check_improve('backstab', False, 1) fight.damage(ch, victim, 0, 'backstab', merc.DAM_NONE, True) return
def do_murder(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Murder whom?\n") return if ch.is_affected(merc.AFF_CHARM) \ or (ch.is_npc() and ch.act.is_set(merc.ACT_PET)): return victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return if victim == ch: ch.send("Suicide is a mortal sin.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and 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) if ch.is_npc(): buf = "Help! I am being attacked by %s!" % ch.short_descr else: buf = "Help! I am being attacked by %s!" % ch.name victim.do_yell(buf) fight.check_killer(ch, victim) fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) return
def do_murder(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Murder whom?\n") return if ch.is_affected(merc.AFF_CHARM) \ or (ch.is_npc() and ch.act.is_set(merc.ACT_PET)): return victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return if victim == ch: ch.send("Suicide is a mortal sin.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and 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) if ch.is_npc(): buf = "Help! I am being attacked by %s!" % ch.short_descr else: buf = "Help! I am being attacked by %s!" % ch.name victim.do_yell(buf) fight.check_killer(ch, victim) fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED) return
def spell_charm_person(sn, level, ch, victim, target): if fight.is_safe(ch, victim): return if victim == ch: ch.send("You like yourself even better! \n") return if ( victim.is_affected( merc.AFF_CHARM) \ or ch.is_affected(merc.AFF_CHARM) \ or level < victim.level \ or state_checks.IS_SET(victim.imm_flags, merc.IMM_CHARM) \ or handler_magic.saves_spell(level, victim, merc.DAM_CHARM) ): return if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_LAW): ch.send("The mayor does not allow charming in the city limits.\n") return if victim.master: handler_ch.stop_follower(victim) handler_ch.add_follower(victim, ch) victim.leader = ch af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level af.duration = game_utils.number_fuzzy(level // 4) af.location = 0 af.modifier = 0 af.bitvector = merc.AFF_CHARM victim.affect_add(af) #TODO: Known broken. Mob will immediately try to fight you after casting this, because this is an offensive spell. #ROM had some stipulation to prevent this combat, possibly in fight.py:is_safe() handler_game.act("Isn't $n just so nice?", ch, None, victim, merc.TO_VICT) if ch is not victim: handler_game.act("$N looks at you with adoring eyes.", ch, None, victim, merc.TO_CHAR)
def 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 obj_cast_spell(sn, level, ch, victim, obj): import const import fight target = merc.TARGET_NONE vo = None if not sn: return if sn not in const.skill_table or not const.skill_table[sn].spell_fun: print("BUG: Obj_cast_spell: bad sn %d." % sn) return sn = const.skill_table[sn] if sn.target == merc.TAR_IGNORE: vo = None elif sn.target == merc.TAR_CHAR_OFFENSIVE: if not victim: victim = ch.fighting if not victim: ch.send("You can't do that.\n") return if fight.is_safe(ch, victim) and ch != victim: ch.send("Something isn't right...\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_DEFENSIVE \ or sn.target == merc.TAR_CHAR_SELF: if not victim: victim = ch vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_OBJ_INV: if not obj: ch.send("You can't do that.\n") return vo = obj target = merc.TARGET_ITEM elif sn.target == merc.TAR_OBJ_CHAR_OFF: if not victim and not obj: if ch.fighting: victim = ch.fighting else: ch.send("You can't do that.\n") return if victim: if fight.is_safe_spell(ch, victim, False) and ch != victim: ch.send("Somehting isn't right...\n") return vo = victim target = merc.TARGET_CHAR else: vo = obj target = merc.TARGET_ITEM elif sn.target == merc.TAR_OBJ_CHAR_DEF: if not victim and not obj: vo = ch target = merc.TARGET_CHAR elif victim: vo = victim target = merc.TARGET_CHAR else: vo = obj target = merc.TARGET_ITEM else: print("BUG: Obj_cast_spell: bad target for sn %s." % sn.name) return target_name = "" sn.spell_fun(sn, level, ch, vo, target) if (sn.target == merc.TAR_CHAR_OFFENSIVE \ or (sn.target == merc.TAR_OBJ_CHAR_OFF and target == merc.TARGET_CHAR)) \ and victim != ch \ and victim.master != ch: for vch in ch.in_room.people[:]: if victim == vch and not victim.fighting: fight.check_killer(victim, ch) fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED)
def cmd_hurl(ch, argument): argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) if not ch.is_npc() and ch.learned["hurl"] < 1: ch.send("Maybe you should learn the skill first?\n") return if not arg1: ch.send("Who do you wish to hurl?\n") return victim = ch.get_char_room(arg1) if not victim: ch.not_here(arg1) return if ch == victim: ch.not_self() return if fight.is_safe(ch, victim): return mount = victim.mount if mount and victim.mounted == merc.IS_MOUNT: ch.send("But they have someone on their back!\n") return if mount and victim.mounted == merc.IS_RIDING: ch.send("But they are riding!\n") return if not victim.is_npc() and victim.immune.is_set(merc.IMM_HURL): ch.send("You are unable to get their feet of the ground.\n") return if victim.is_npc() and victim.level > 900: ch.send("You are unable to get their feet of the ground.\n") return if victim.hit < victim.max_hit or (victim.position == merc.POS_FIGHTING and victim.fighting != ch): handler_game.act("$N is hurt and suspicious, and you are unable to approach $M.", ch, None, victim, merc.TO_CHAR) return ch.wait_state(const.skill_table["hurl"].beats) if not ch.is_npc() and game_utils.number_percent() > ch.learned["hurl"]: ch.send("You are unable to get their feet of the ground.\n") fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) return if not arg2: door = game_utils.number_range(0, 3) else: if game_utils.str_cmp(arg2, ["n", "north"]): door = merc.DIR_NORTH elif game_utils.str_cmp(arg2, ["e", "east"]): door = merc.DIR_EAST elif game_utils.str_cmp(arg2, ["s", "south"]): door = merc.DIR_SOUTH elif game_utils.str_cmp(arg2, ["w", "west"]): door = merc.DIR_WEST else: ch.send("You can only hurl people north, south, east or west.\n") return if door == merc.DIR_NORTH: direction = "north" rev_dir = 2 elif door == merc.DIR_EAST: direction = "east" rev_dir = 3 elif door == merc.DIR_SOUTH: direction = "south" rev_dir = 0 else: direction = "west" rev_dir = 1 pexit = ch.in_room.exit[door] to_room = instance.rooms[pexit.to_room] if pexit else None if not pexit or not to_room: handler_game.act("$n hurls $N into the $t wall.", ch, direction, victim, merc.TO_NOTVICT) handler_game.act("You hurl $N into the $t wall.", ch, direction, victim, merc.TO_CHAR) handler_game.act("$n hurls you into the $t wall.", ch, direction, victim, merc.TO_VICT) dam = game_utils.number_range(ch.level, (ch.level * 4)) victim.hit -= dam fight.update_pos(victim) if victim.is_npc() and not ch.is_npc(): ch.mkill += 1 if not victim.is_npc() and ch.is_npc(): victim.mdeath += 1 if victim.position == merc.POS_DEAD: fight.raw_kill(victim) return return pexit = victim.in_room.exit[door] if pexit.exit_info.is_set(merc.EX_CLOSED) and not victim.is_affected(merc.AFF_PASS_DOOR) and not victim.is_affected(merc.AFF_ETHEREAL): pexit.exit_info.rem_bit(merc.EX_LOCKED) pexit.exit_info.rem_bit(merc.EX_CLOSED) handler_game.act("$n hoists $N in the air and hurls $M $t.", ch, direction, victim, merc.TO_NOTVICT) handler_game.act("You hoist $N in the air and hurl $M $t.", ch, direction, victim, merc.TO_CHAR) handler_game.act("$n hurls you $t, smashing you through the {}.".format(pexit.keyword), ch, direction, victim, merc.TO_VICT) handler_game.act("There is a loud crash as $n smashes through the $d.", victim, None, pexit.keyword, merc.TO_ROOM) to_room = pexit.to_room pexit_rev = instance.rooms[to_room].exit[rev_dir] if to_room and pexit_rev and pexit_rev.to_room == ch.in_room and pexit_rev.keyword: pexit_rev.exit_info.rem_bit(merc.EX_LOCKED) pexit_rev.exit_info.rem_bit(merc.EX_CLOSED) if door == 0: direction = "south" elif door == 1: direction = "west" elif door == 2: direction = "north" else: direction = "east" victim.in_room.get(victim) to_room.put(victim) handler_game.act("$n comes smashing in through the $t $d.", victim, direction, pexit.keyword, merc.TO_ROOM) dam = game_utils.number_range(ch.level, (ch.level * 6)) victim.hit -= dam fight.update_pos(victim) if victim.is_npc() and not ch.is_npc(): ch.mkill += 1 if not victim.is_npc() and ch.is_npc(): victim.mdeath += 1 if victim.position == merc.POS_DEAD: fight.raw_kill(victim) else: handler_game.act("$n hurls $N $t.", ch, direction, victim, merc.TO_NOTVICT) handler_game.act("You hurl $N $t.", ch, direction, victim, merc.TO_CHAR) handler_game.act("$n hurls you $t.", ch, direction, victim, merc.TO_VICT) if door == 0: direction = "south" elif door == 1: direction = "west" elif door == 2: direction = "north" else: direction = "east" victim.in_room.get(victim) to_room.put(victim) handler_game.act("$n comes flying in from the $t.", victim, direction, None, merc.TO_ROOM) dam = game_utils.number_range(ch.level, (ch.level * 2)) victim.hit -= dam fight.update_pos(victim) if victim.is_npc() and not ch.is_npc(): ch.mkill += 1 if not victim.is_npc() and ch.is_npc(): victim.mdeath += 1 if victim.position == merc.POS_DEAD: fight.raw_kill(victim)
def do_trip(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('trip') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_TRIP)) \ or ( not ch.is_npc() and ch.level < const.skill_table['trip'].skill_level[ch.guild.name]): ch.send("Tripping? What's that?\n\r") return if not arg: victim = ch.fighting if victim is None: ch.send("But you aren't fighting anyone!\n\r") return else: victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n\r") return if fight.is_safe(ch,victim): return if victim.is_npc() and victim.fighting and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n\r") return if victim.is_affected( merc.AFF_FLYING): handler_game.act("$S feet aren't on the ground.",ch,None,victim, merc.TO_CHAR) return if victim.position < merc.POS_FIGHTING: handler_game.act("$N is already down.",ch,None,victim, merc.TO_CHAR) return if victim == ch: ch.send("You fall flat on your face!\n\r") state_checks.WAIT_STATE(ch,2 * const.skill_table['trip'].beats) handler_game.act("$n trips over $s own feet!",ch,None,None, merc.TO_ROOM) 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 # modifiers */ # size */ if ch.size < victim.size: chance += (ch.size - victim.size) * 10 # bigger = harder to trip */ # dex */ chance += ch.stat(merc.STAT_DEX) chance -= victim.stat(merc.STAT_DEX) * 3 // 2 # speed */ if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected(merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 20 # level */ chance += (ch.level - victim.level) * 2 # now the attack */ if random.randint(1,99) < chance: handler_game.act("$n trips you and you go down!",ch,None,victim, merc.TO_VICT) handler_game.act("You trip $N and $N goes down!",ch,None,victim, merc.TO_CHAR) handler_game.act("$n trips $N, sending $M to the ground.",ch,None,victim, merc.TO_NOTVICT) if ch.is_pc(): ch.check_improve('trip', True, 1) state_checks.DAZE_STATE(victim,2 * merc.PULSE_VIOLENCE) state_checks.WAIT_STATE(ch,const.skill_table['trip'].beats) victim.position = merc.POS_RESTING fight.damage(ch,victim,random.randint(2, 2 + 2 * victim.size),'trip', merc.DAM_BASH,True) else: fight.damage(ch,victim,0,'trip', merc.DAM_BASH,True) state_checks.WAIT_STATE(ch,const.skill_table['trip'].beats*2 // 3) if ch.is_pc(): ch.check_improve('trip', False, 1) fight.check_killer(ch,victim)
def do_dirt(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('dirt kicking') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_KICK_DIRT)) \ or ( not ch.is_npc() and ch.level < const.skill_table['dirt kicking'].skill_level[ch.guild.name]): ch.send("You get your feet dirty.\n") return if not arg: victim = ch.fighting if victim is None: ch.send("But you aren't in combat!\n") return else: victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return if victim.is_affected(merc.AFF_BLIND): handler_game.act("$E's already been blinded.", ch, None, victim, merc.TO_CHAR) return if victim == ch: ch.send("Very funny.\n") return if fight.is_safe(ch, victim): return if victim.is_npc( ) and victim.fighting is not None 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("But $N is such a good friend!", ch, None, victim, merc.TO_CHAR) return # modifiers # dexterity chance += ch.stat(merc.STAT_DEX) chance -= 2 * victim.stat(merc.STAT_DEX) # speed if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected( merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 25 # level chance += (ch.level - victim.level) * 2 # sloppy hack to prevent false zeroes if chance % 5 == 0: chance += 1 # terrain nochance = [merc.SECT_WATER_SWIM, merc.SECT_WATER_NOSWIM, merc.SECT_AIR] modifiers = { merc.SECT_INSIDE: -20, merc.SECT_CITY: -10, merc.SECT_FIELD: 5, merc.SECT_MOUNTAIN: -10, merc.SECT_DESERT: 10 } if ch.in_room.sector_type in nochance: chance = 0 elif ch.in_room.sector_type in modifiers: chance += modifiers[ch.in_room.sector_type] if chance == 0: ch.send("There isn't any dirt to kick.\n") return # now the attack if random.randint(1, 99) < chance: handler_game.act("$n is blinded by the dirt in $s eyes!", victim, None, None, merc.TO_ROOM) handler_game.act("$n kicks dirt in your eyes!", ch, None, victim, merc.TO_VICT) fight.damage(ch, victim, random.randint(2, 5), 'dirt kicking', merc.DAM_NONE, False) victim.send("You can't see a thing!\n") if ch.is_pc(): ch.check_improve('dirt kicking', True, 2) state_checks.WAIT_STATE(ch, const.skill_table['dirt kicking'].beats) af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = 'dirt kicking' af.level = ch.level af.duration = 0 af.location = merc.APPLY_HITROLL af.modifier = -4 af.bitvector = merc.AFF_BLIND victim.affect_add(af) else: fight.damage(ch, victim, 0, 'dirt kicking', merc.DAM_NONE, True) if ch.is_pc(): ch.check_improve('dirt kicking', False, 2) state_checks.WAIT_STATE(ch, const.skill_table['dirt kicking'].beats) fight.check_killer(ch, victim)
def do_trip(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('trip') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_TRIP)) \ or ( not ch.is_npc() and ch.level < const.skill_table['trip'].skill_level[ch.guild.name]): ch.send("Tripping? What's that?\n\r") return if not arg: victim = ch.fighting if victim is None: ch.send("But you aren't fighting anyone!\n\r") return else: victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n\r") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.fighting and not ch.is_same_group( victim.fighting): ch.send("Kill stealing is not permitted.\n\r") return if victim.is_affected(merc.AFF_FLYING): handler_game.act("$S feet aren't on the ground.", ch, None, victim, merc.TO_CHAR) return if victim.position < merc.POS_FIGHTING: handler_game.act("$N is already down.", ch, None, victim, merc.TO_CHAR) return if victim == ch: ch.send("You fall flat on your face!\n\r") state_checks.WAIT_STATE(ch, 2 * const.skill_table['trip'].beats) handler_game.act("$n trips over $s own feet!", ch, None, None, merc.TO_ROOM) 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 # modifiers */ # size */ if ch.size < victim.size: chance += (ch.size - victim.size) * 10 # bigger = harder to trip */ # dex */ chance += ch.stat(merc.STAT_DEX) chance -= victim.stat(merc.STAT_DEX) * 3 // 2 # speed */ if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected( merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 20 # level */ chance += (ch.level - victim.level) * 2 # now the attack */ if random.randint(1, 99) < chance: handler_game.act("$n trips you and you go down!", ch, None, victim, merc.TO_VICT) handler_game.act("You trip $N and $N goes down!", ch, None, victim, merc.TO_CHAR) handler_game.act("$n trips $N, sending $M to the ground.", ch, None, victim, merc.TO_NOTVICT) if ch.is_pc(): ch.check_improve('trip', True, 1) state_checks.DAZE_STATE(victim, 2 * merc.PULSE_VIOLENCE) state_checks.WAIT_STATE(ch, const.skill_table['trip'].beats) victim.position = merc.POS_RESTING fight.damage(ch, victim, random.randint(2, 2 + 2 * victim.size), 'trip', merc.DAM_BASH, True) else: fight.damage(ch, victim, 0, 'trip', merc.DAM_BASH, True) state_checks.WAIT_STATE(ch, const.skill_table['trip'].beats * 2 // 3) if ch.is_pc(): ch.check_improve('trip', False, 1) fight.check_killer(ch, victim)
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 do_dirt(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('dirt kicking') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_KICK_DIRT)) \ or ( not ch.is_npc() and ch.level < const.skill_table['dirt kicking'].skill_level[ch.guild.name]): ch.send("You get your feet dirty.\n") return if not arg: victim = ch.fighting if victim is None: ch.send("But you aren't in combat!\n") return else: victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return if victim.is_affected( merc.AFF_BLIND): handler_game.act("$E's already been blinded.", ch, None, victim, merc.TO_CHAR) return if victim == ch: ch.send("Very funny.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.fighting is not None 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("But $N is such a good friend!", ch, None, victim, merc.TO_CHAR) return # modifiers # dexterity chance += ch.stat(merc.STAT_DEX) chance -= 2 * victim.stat(merc.STAT_DEX) # speed if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected(merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 25 # level chance += (ch.level - victim.level) * 2 # sloppy hack to prevent false zeroes if chance % 5 == 0: chance += 1 # terrain nochance = [merc.SECT_WATER_SWIM, merc.SECT_WATER_NOSWIM, merc.SECT_AIR] modifiers = {merc.SECT_INSIDE: -20, merc.SECT_CITY: -10, merc.SECT_FIELD: 5, merc.SECT_MOUNTAIN: -10, merc.SECT_DESERT: 10 } if ch.in_room.sector_type in nochance: chance = 0 elif ch.in_room.sector_type in modifiers: chance += modifiers[ch.in_room.sector_type] if chance == 0: ch.send("There isn't any dirt to kick.\n") return # now the attack if random.randint(1, 99) < chance: handler_game.act("$n is blinded by the dirt in $s eyes!", victim, None, None, merc.TO_ROOM) handler_game.act("$n kicks dirt in your eyes!", ch, None, victim, merc.TO_VICT) fight.damage(ch, victim, random.randint(2, 5), 'dirt kicking', merc.DAM_NONE, False) victim.send("You can't see a thing!\n") if ch.is_pc(): ch.check_improve( 'dirt kicking', True, 2) state_checks.WAIT_STATE(ch, const.skill_table['dirt kicking'].beats) af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = 'dirt kicking' af.level = ch.level af.duration = 0 af.location = merc.APPLY_HITROLL af.modifier = -4 af.bitvector = merc.AFF_BLIND victim.affect_add(af) else: fight.damage(ch, victim, 0, 'dirt kicking', merc.DAM_NONE, True) if ch.is_pc(): ch.check_improve( 'dirt kicking', False, 2) state_checks.WAIT_STATE(ch, const.skill_table['dirt kicking'].beats) fight.check_killer(ch, victim)
def cmd_decapitate(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return item = ch.get_eq("right_hand") if not item or item.item_type != merc.ITEM_WEAPON: item = ch.get_eq("left_hand") if not item or item.item_type != merc.ITEM_WEAPON: ch.send("But you are not wielding any weapons!\n") return if item.value[3] not in [1, 3]: ch.send( "You need to wield a slashing or slicing weapon to decapitate.\n") return if not arg: ch.send("Decapitate 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.send("You can only decapitate other players.\n") return if not ch.can_pk(): ch.send("You must be an avatar to decapitate someone.\n") return if not victim.can_pk(): ch.send("You can only decapitate other avatars.\n") return if victim.position > merc.POS_MORTAL: ch.send("You can only do this to mortally wounded players.\n") return if fight.is_safe(ch, victim): return if ch.is_vampire() and ch.special.is_set( merc.SPC_INCONNU) and (victim.is_vampire() or victim.vampaff.is_set(merc.VAM_MORTAL)): ch.send("You cannot decapitate another vampire.\n") return if victim.is_vampire() and victim.special.is_set( merc.SPC_INCONNU) and (ch.is_vampire() or ch.vampaff.is_set(merc.VAM_MORTAL)): ch.send("You cannot decapitate an Inconnu vampire.\n") return if ch.is_vampire() and victim.is_vampire() and ch.clan and victim.clan: if game_utils.str_cmp(ch.clan, victim.clan): ch.send("You cannot decapitate someone of your own clan.\n") return handler_game.act("You bring your weapon down upon $N's neck!", ch, None, victim, merc.TO_CHAR) victim.send("Your head is sliced from your shoulders!\n") handler_game.act("$n swings $s weapon down towards $N's neck!", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n's head is sliced from $s shoulders!", victim, None, None, merc.TO_ROOM) if ch.is_demon() or ch.special.is_set( merc.SPC_CHAMPION) and not victim.is_demon( ) and not victim.special.is_set(merc.SPC_CHAMPION): if ch.race == 0 and victim.race == 0: ch.powers[merc.DEMON_CURRENT] += 1000 ch.powers[merc.DEMON_TOTAL] += 1000 else: ch.powers[merc.DEMON_CURRENT] += victim.race * 1000 ch.powers[merc.DEMON_TOTAL] += victim.race * 1000 if victim.race < 1 and ch.race > 0: comm.info("{} has been decapitated by {} for no status.".format( victim.name, ch.name)) comm.notify( "{} decapitated by {} at {} for no status.".format( victim.name, ch.name, victim.in_room.vnum), merc.CONSOLE_INFO) if victim.is_vampire(): victim.mortalvamp() elif victim.special.is_set(merc.SPC_WOLFMAN): victim.unwerewolf() if victim.is_mage() and victim.is_affected(merc.AFF_POLYMORPH): victim.cmd_unpolymorph("") fight.behead(victim) ch.beastlike() ch.pkill += 1 victim.pdeath += 1 return ch.exp += 1000 if ch.race - ((ch.race // 100) * 100) == 0: ch.race += 1 elif ch.race - ((ch.race // 100) * 100) < 25: ch.race += 1 if ch.race - ((ch.race // 100) * 100) == 0: victim.race = victim.race elif victim.race - ((victim.race // 100) * 100) > 0: victim.race += 1 handler_game.act( "A misty white vapour pours from $N's corpse into your body.", ch, None, victim, merc.TO_CHAR) handler_game.act( "A misty white vapour pours from $N's corpse into $n's body.", ch, None, victim, merc.TO_NOTVICT) handler_game.act( "You double over in agony as raw energy pulses through your veins.", ch, None, None, merc.TO_CHAR) handler_game.act( "$n doubles over in agony as sparks of energy crackle around $m.", ch, None, None, merc.TO_NOTVICT) if victim.is_vampire(): victim.mortalvamp() elif victim.special.is_set(merc.SPC_WOLFMAN): victim.unwerewolf() if victim.is_mage() and victim.is_affected(merc.AFF_POLYMORPH): victim.cmd_unpolymorph("") fight.behead(victim) ch.beastlike() ch.pkill += 1 victim.pdeath += 1 victim.powers[merc.UNI_RAGE] = 0 victim.level = 2 comm.info("{} has been decapitated by {}.".format(victim.name, ch.name)) comm.notify( "{} decapitated by {} at {}.".format(victim.name, ch.name, victim.in_room.vnum), merc.CONSOLE_INFO)
def cmd_tear(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return if not ch.is_werewolf(): ch.huh() return if not ch.special.is_set(merc.SPC_WOLFMAN): ch.send("You can only tear heads off while in Crinos form.\n") return if not ch.vampaff.is_set(merc.VAM_CLAWS): ch.send("You better get your claws out first.\n") return if not arg: ch.send("Who's head do you wish to tear off?\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.send("You can only tear the heads off other players.\n") return if not ch.can_pk(): ch.send("You must be an avatar to tear someone's head off.\n") return if not victim.can_pk(): ch.send("You can only tear the head off another avatar.\n") return if victim.position > merc.POS_MORTAL: ch.send("You can only do this to mortally wounded players.\n") return if fight.is_safe(ch, victim): return handler_game.act("You tear $N's head from $S shoulders!", ch, None, victim, merc.TO_CHAR) victim.send("Your head is torn from your shoulders!\n") handler_game.act("$n tears $N's head from $S shoulders!", ch, None, victim, merc.TO_NOTVICT) if ch.is_demon() or ch.special.is_set(merc.SPC_CHAMPION): if ch.race == 0 and victim.race == 0: ch.powers[merc.DEMON_CURRENT] += 1000 ch.powers[merc.DEMON_TOTAL] += 1000 else: ch.powers[merc.DEMON_CURRENT] += victim.race * 1000 ch.powers[merc.DEMON_TOTAL] += victim.race * 1000 if victim.race < 1 and ch.race > 0: comm.info("{} has been decapitated by {}.".format( victim.name, ch.name)) comm.notify( "{} decapitated by {} at {} for no status.".format( victim.name, ch.name, victim.in_room.vnum), merc.CONSOLE_INFO) if victim.is_vampire(): victim.mortalvamp() elif victim.special.is_set(merc.SPC_WOLFMAN): victim.unwerewolf() if victim.is_mage() and victim.is_affected(merc.AFF_POLYMORPH): victim.cmd_unpolymorph("") fight.behead(victim) ch.beastlike() ch.pkill += 1 victim.pdeath += 1 return ch.exp += 1000 if ch.race - ((ch.race // 100) * 100) == 0: ch.race = ch.race + 1 elif ch.race - ((ch.race // 100) * 100) < 25: ch.race = ch.race + 1 if ch.race - ((ch.race // 100) * 100) == 0: victim.race = victim.race elif victim.race - ((victim.race // 100) * 100) > 0: victim.race = victim.race - 1 handler_game.act( "A misty white vapour pours from $N's corpse into your body.", ch, None, victim, merc.TO_CHAR) handler_game.act( "A misty white vapour pours from $N's corpse into $n's body.", ch, None, victim, merc.TO_NOTVICT) handler_game.act( "You double over in agony as raw energy pulses through your veins.", ch, None, None, merc.TO_CHAR) handler_game.act( "$n doubles over in agony as sparks of energy crackle around $m.", ch, None, None, merc.TO_NOTVICT) if victim.is_vampire(): victim.mortalvamp() elif victim.special.is_set(merc.SPC_WOLFMAN): victim.unwerewol() if victim.is_mage() and victim.is_affected(merc.AFF_POLYMORPH): victim.cmd_unpolymorph("") fight.behead(victim) ch.beastlike() ch.pkill += 1 victim.pdeath += 1 victim.powers[merc.UNI_RAGE] = 0 victim.level = 2 comm.info("{} has been decapitated by {}.".format(victim.name, ch.name)) comm.notify( "{} decapitated by {} at {}.".format(victim.name, ch.name, victim.in_room.vnum), merc.CONSOLE_INFO)
def do_cast(ch, argument): # Switched NPC's can cast spells, but others can't. if ch.is_npc() and not ch.desc: return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) handler_magic.target_name = arg2 if not arg1: ch.send("Cast which what where?\n") return sn = handler_magic.find_spell(ch, arg1) if not sn or sn.spell_fun is None \ or (not ch.is_npc() and (ch.level < sn.skill_level[ch.guild.name] or ch.learned.get(sn.name, 0) == 0)): ch.send("You don't know any spells of that name.\n") return if ch.position < sn.minimum_position: ch.send("You can't concentrate enough.\n") return if ch.level + 2 == sn.skill_level[ch.guild.name]: mana = 50 else: mana = max(sn.min_mana, 100 // (2 + ch.level - sn.skill_level[ch.guild.name])) # Locate targets. victim = None obj = None vo = None target = merc.TARGET_NONE if sn.target == merc.TAR_IGNORE: pass elif sn.target == merc.TAR_CHAR_OFFENSIVE: if not arg2: victim = ch.fighting if not victim: ch.send("Cast the spell on whom?\n") return else: victim = ch.get_char_room(arg2) if not victim: ch.send("They aren't here.\n") return # if ch == victim: # ch.send("You can't do that to yourself.\n") # return if not ch.is_npc(): if fight.is_safe(ch, victim) and victim != ch: ch.send("Not on that target.\n") return fight.check_killer(ch, victim) if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: ch.send("You can't do that on your own follower.\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_DEFENSIVE: if not arg2: victim = ch else: victim = ch.get_char_room(handler_magic.target_name) if not victim: ch.send("They aren't here.\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_SELF: if arg2 and handler_magic.target_name not in ch.name.lower(): ch.send("You can't cast this spell on another.\n") return vo = ch target = merc.TARGET_CHAR elif sn.target == merc.TAR_OBJ_INV: if not arg2: ch.send("What should the spell be cast upon?\n") return obj = ch.get_item_carry(handler_magic.target_name, ch) if not obj: ch.send("You are not carrying that.\n") return vo = obj target = merc.TARGET_ITEM elif sn.target == merc.TAR_OBJ_CHAR_OFF: if not arg2: victim = ch.fighting if not victim: ch.send("Cast the spell on whom or what?\n") return target = merc.TARGET_CHAR else: victim = ch.get_char_room(handler_magic.target_name) obj = ch.get_item_here(handler_magic.target_name) if victim: target = merc.TARGET_CHAR # check the sanity of the attack if fight.is_safe_spell(ch, victim, False) and victim != ch: ch.send("Not on that target.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: ch.send("You can't do that on your own follower.\n") return if not ch.is_npc(): fight.check_killer(ch, victim) vo = victim elif obj: vo = obj target = merc.TARGET_ITEM else: ch.send("You don't see that here.\n") return elif sn.target == merc.TAR_OBJ_CHAR_DEF: if not arg2: vo = ch target = merc.TARGET_CHAR else: victim = ch.get_char_room(handler_magic.target_name) obj = ch.get_item_carry(handler_magic.target_name, ch) if not victim: vo = victim target = merc.TARGET_CHAR elif not obj: vo = obj target = merc.TARGET_ITEM else: ch.send("You don't see that here.\n") return else: logging.error("BUG: Do_cast: bad target for sn %s.", sn) return if not ch.is_npc() and ch.mana < mana: ch.send("You don't have enough mana.\n") return if sn.name != "ventriloquate": handler_magic.say_spell(ch, sn) state_checks.WAIT_STATE(ch, sn.beats) if random.randint(1, 99) > ch.get_skill(sn.name): ch.send("You lost your concentration.\n") if ch.is_pc(): ch.check_improve(sn, False, 1) ch.mana -= mana // 2 else: ch.mana -= mana if ch.is_npc() or ch.guild.fMana: # class has spells sn.spell_fun(sn, ch.level, ch, vo, target) else: sn.spell_fun(sn, 3 * ch.level // 4, ch, vo, target) if ch.is_pc(): ch.check_improve(sn, True, 1) if (sn.target == merc.TAR_CHAR_OFFENSIVE or (sn.target == merc.TAR_OBJ_CHAR_OFF and target == merc.TARGET_CHAR)) \ and victim != ch and victim.master != ch: for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if victim == vch and not victim.fighting: fight.check_killer(victim, ch) fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) break return
def do_cast(ch, argument): # Switched NPC's can cast spells, but others can't. if ch.is_npc() and not ch.desc: return argument, arg1 = game_utils.read_word(argument) argument, arg2 = game_utils.read_word(argument) handler_magic.target_name = arg2 if not arg1: ch.send("Cast which what where?\n") return sn = handler_magic.find_spell(ch, arg1) if not sn or sn.spell_fun is None \ or (not ch.is_npc() and (ch.level < sn.skill_level[ch.guild.name] or ch.learned.get(sn.name, 0) == 0)): ch.send("You don't know any spells of that name.\n") return if ch.position < sn.minimum_position: ch.send("You can't concentrate enough.\n") return if ch.level + 2 == sn.skill_level[ch.guild.name]: mana = 50 else: mana = max(sn.min_mana, 100 // (2 + ch.level - sn.skill_level[ch.guild.name])) # Locate targets. victim = None obj = None vo = None target = merc.TARGET_NONE if sn.target == merc.TAR_IGNORE: pass elif sn.target == merc.TAR_CHAR_OFFENSIVE: if not arg2: victim = ch.fighting if not victim: ch.send("Cast the spell on whom?\n") return else: victim = ch.get_char_room(arg2) if not victim: ch.send("They aren't here.\n") return # if ch == victim: # ch.send("You can't do that to yourself.\n") # return if not ch.is_npc(): if fight.is_safe(ch, victim) and victim != ch: ch.send("Not on that target.\n") return fight.check_killer(ch, victim) if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: ch.send("You can't do that on your own follower.\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_DEFENSIVE: if not arg2: victim = ch else: victim = ch.get_char_room(handler_magic.target_name) if not victim: ch.send("They aren't here.\n") return vo = victim target = merc.TARGET_CHAR elif sn.target == merc.TAR_CHAR_SELF: if arg2 and handler_magic.target_name not in ch.name.lower(): ch.send("You can't cast this spell on another.\n") return vo = ch target = merc.TARGET_CHAR elif sn.target == merc.TAR_OBJ_INV: if not arg2: ch.send("What should the spell be cast upon?\n") return obj = ch.get_item_carry(handler_magic.target_name, ch) if not obj: ch.send("You are not carrying that.\n") return vo = obj target = merc.TARGET_ITEM elif sn.target == merc.TAR_OBJ_CHAR_OFF: if not arg2: victim = ch.fighting if not victim: ch.send("Cast the spell on whom or what?\n") return target = merc.TARGET_CHAR else: victim = ch.get_char_room(handler_magic.target_name) obj = ch.get_item_here(handler_magic.target_name) if victim: target = merc.TARGET_CHAR # check the sanity of the attack if fight.is_safe_spell(ch, victim, False) and victim != ch: ch.send("Not on that target.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: ch.send("You can't do that on your own follower.\n") return if not ch.is_npc(): fight.check_killer(ch, victim) vo = victim elif obj: vo = obj target = merc.TARGET_ITEM else: ch.send("You don't see that here.\n") return elif sn.target == merc.TAR_OBJ_CHAR_DEF: if not arg2: vo = ch target = merc.TARGET_CHAR else: victim = ch.get_char_room(handler_magic.target_name) obj = ch.get_item_carry(handler_magic.target_name, ch) if not victim: vo = victim target = merc.TARGET_CHAR elif not obj: vo = obj target = merc.TARGET_ITEM else: ch.send("You don't see that here.\n") return else: logging.error("BUG: Do_cast: bad target for sn %s.", sn) return if not ch.is_npc() and ch.mana < mana: ch.send("You don't have enough mana.\n") return if sn.name != "ventriloquate": handler_magic.say_spell(ch, sn) state_checks.WAIT_STATE(ch, sn.beats) if random.randint(1, 99) > ch.get_skill(sn.name): ch.send("You lost your concentration.\n") if ch.is_pc(): ch.check_improve( sn, False, 1) ch.mana -= mana // 2 else: ch.mana -= mana if ch.is_npc() or ch.guild.fMana: # class has spells sn.spell_fun(sn, ch.level, ch, vo, target) else: sn.spell_fun(sn, 3 * ch.level // 4, ch, vo, target) if ch.is_pc(): ch.check_improve( sn, True, 1) if (sn.target == merc.TAR_CHAR_OFFENSIVE or (sn.target == merc.TAR_OBJ_CHAR_OFF and target == merc.TARGET_CHAR)) \ and victim != ch and victim.master != ch: for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if victim == vch and not victim.fighting: fight.check_killer(victim, ch) fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED) break return
def do_bash(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('bash') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_BASH)) \ or (not ch.is_npc() and ch.level < const.skill_table['bash'].skill_level[ch.guild.name] ): ch.send("Bashing? What's that?\n\r") return victim = None if not arg: victim = ch.fighting if not victim: ch.send("But you aren't fighting anyone!\n") return else: victim = ch.get_char_room(arg) if not victim: ch.send("They aren't here.\n") return if victim.position < merc.POS_FIGHTING: handler_game.act("You'll have to let $M get back up first.", ch, None, victim, merc.TO_CHAR) return if victim == ch: ch.send("You try to bash your brains out, but fail.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.fighting and not ch.is_same_group( victim.fighting): ch.send("Kill stealing is not permitted.\n\r") return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: handler_game.act("But $N is your friend!", ch, None, victim, merc.TO_CHAR) return # modifiers # size and weight chance += ch.carry_weight // 250 chance -= victim.carry_weight // 200 if ch.size < victim.size: chance += (ch.size - victim.size) * 15 else: chance += (ch.size - victim.size) * 10 # stats chance += ch.stat(merc.STAT_STR) chance -= (victim.stat(merc.STAT_DEX) * 4) // 3 chance -= state_checks.GET_AC(victim, merc.AC_BASH) // 25 # speed */ if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected( merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 30 # level chance += (ch.level - victim.level) if not victim.is_npc() and chance < victim.get_skill('dodge'): pass # act("$n tries to bash you, but you dodge it.",ch,None,victim,TO_VICT) # act("$N dodges your bash, you fall flat on your face.",ch,None,victim,TO_CHAR) # WAIT_STATE(ch,const.skill_table['bash'].beats) # return chance -= 3 * (victim.get_skill('dodge') - chance) # now the attack */ if random.randint(1, 99) < chance: handler_game.act("$n sends you sprawling with a powerful bash!", ch, None, victim, merc.TO_VICT) handler_game.act("You slam into $N, and send $M flying!", ch, None, victim, merc.TO_CHAR) handler_game.act("$n sends $N sprawling with a powerful bash.", ch, None, victim, merc.TO_NOTVICT) if not ch.is_npc(): if ch.is_pc(): ch.check_improve('bash', True, 1) state_checks.DAZE_STATE(victim, 3 * merc.PULSE_VIOLENCE) state_checks.WAIT_STATE(ch, const.skill_table['bash'].beats) victim.position = merc.POS_RESTING fight.damage(ch, victim, random.randint(2, 2 + 2 * ch.size + chance // 20), 'bash', merc.DAM_BASH, False) else: fight.damage(ch, victim, 0, 'bash', merc.DAM_BASH, False) handler_game.act("You fall flat on your face!", ch, None, victim, merc.TO_CHAR) handler_game.act("$n falls flat on $s face.", ch, None, victim, merc.TO_NOTVICT) handler_game.act( "You evade $n's bash, causing $m to fall flat on $s face.", ch, None, victim, merc.TO_VICT) if not ch.is_npc(): if ch.is_pc(): ch.check_improve('bash', False, 1) ch.position = merc.POS_RESTING state_checks.WAIT_STATE(ch, const.skill_table['bash'].beats * 3 // 2) fight.check_killer(ch, victim)
def cmd_punch(ch, argument): argument, arg = game_utils.read_word(argument) if ch.is_npc(): return if ch.level < const.skill_table["punch"].skill_level: ch.send("First you should learn to punch.\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if ch == victim: ch.not_self() return if fight.is_safe(ch, victim): return if victim.hit < victim.max_hit: ch.send("They are hurt and suspicious.\n") return if victim.position < merc.POS_FIGHTING: ch.send("You can only punch someone who is standing.\n") return ch.wait_state(const.skill_table["punch"].beats) if ch.is_npc() or game_utils.number_percent() < ch.learned["punch"]: dam = game_utils.number_range(1, 4) else: fight.damage(ch, victim, 0, "punch") return dam += ch.damroll if dam == 0: dam = 1 if not victim.is_awake(): dam *= 2 if not ch.is_npc(): dam += (dam * (ch.wpn[0] // 100)) if dam <= 0: dam = 1 if not victim.is_npc() and victim.is_werewolf( ) and victim.powers[merc.WPOWER_BOAR] > 3: fight.damage(ch, victim, 0, "punch") if game_utils.number_percent() <= 25 and not ch.arm_left.is_set( merc.LOST_ARM) and not ch.arm_left.is_set(merc.LOST_HAND): broke = False if not ch.arm_left.is_set( merc.LOST_FINGER_I) and not ch.arm_left.is_set( merc.BROKEN_FINGER_I): ch.arm_left.set_bit(merc.BROKEN_FINGER_I) broke = True if not ch.arm_left.is_set( merc.LOST_FINGER_M) and not ch.arm_left.is_set( merc.BROKEN_FINGER_M): ch.arm_left.set_bit(merc.BROKEN_FINGER_M) broke = True if not ch.arm_left.is_set( merc.LOST_FINGER_R) and not ch.arm_left.is_set( merc.BROKEN_FINGER_R): ch.arm_left.set_bit(merc.BROKEN_FINGER_R) broke = True if not ch.arm_left.is_set( merc.LOST_FINGER_L) and not ch.arm_left.is_set( merc.BROKEN_FINGER_L): ch.arm_left.set_bit(merc.BROKEN_FINGER_L) broke = True if broke: handler_game.act( "The fingers on your left hand shatter under the impact of the blow!", ch, None, None, merc.TO_CHAR) handler_game.act( "The fingers on $n's left hand shatter under the impact of the blow!", ch, None, None, merc.TO_ROOM) elif game_utils.number_percent() <= 25 and not ch.arm_right.is_set( merc.LOST_ARM) and not ch.arm_right.is_set(merc.LOST_HAND): broke = False if not ch.arm_right.is_set( merc.LOST_FINGER_I) and not ch.arm_right.is_set( merc.BROKEN_FINGER_I): ch.arm_right.set_bit(merc.BROKEN_FINGER_I) broke = True if not ch.arm_right.is_set( merc.LOST_FINGER_M) and not ch.arm_right.is_set( merc.BROKEN_FINGER_M): ch.arm_right.set_bit(merc.BROKEN_FINGER_M) broke = True if not ch.arm_right.is_set( merc.LOST_FINGER_R) and not ch.arm_right.is_set( merc.BROKEN_FINGER_R): ch.arm_right.set_bit(merc.BROKEN_FINGER_R) broke = True if not ch.arm_right.is_set( merc.LOST_FINGER_L) and not ch.arm_right.is_set( merc.BROKEN_FINGER_L): ch.arm_right.set_bit(merc.BROKEN_FINGER_L) broke = True if broke: handler_game.act( "The fingers on your right hand shatter under the impact of the blow!", ch, None, None, merc.TO_CHAR) handler_game.act( "The fingers on $n's right hand shatter under the impact of the blow! ", ch, None, None, merc.TO_ROOM) fight.stop_fighting(victim, True) return fight.damage(ch, victim, dam, "punch") if not victim or victim.position == merc.POS_DEAD or dam < 1: return if victim.position == merc.POS_FIGHTING: fight.stop_fighting(victim, True) if game_utils.number_percent() <= 25 and not victim.head.is_set( merc.BROKEN_NOSE) and not victim.head.is_set(merc.LOST_NOSE): handler_game.act("Your nose shatters under the impact of the blow!", victim, None, None, merc.TO_CHAR) handler_game.act("$n's nose shatters under the impact of the blow!", victim, None, None, merc.TO_ROOM) victim.head.set_bit(merc.BROKEN_NOSE) elif game_utils.number_percent() <= 25 and not victim.head.is_set( merc.BROKEN_JAW): handler_game.act("Your jaw shatters under the impact of the blow!", victim, None, None, merc.TO_CHAR) handler_game.act("$n's jaw shatters under the impact of the blow!", victim, None, None, merc.TO_ROOM) victim.head.set_bit(merc.BROKEN_JAW) handler_game.act("You fall to the ground stunned!", victim, None, None, merc.TO_CHAR) handler_game.act("$n falls to the ground stunned!", victim, None, None, merc.TO_ROOM) victim.position = merc.POS_STUNNED
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