Exemplo n.º 1
0
def gain_condition(ch, value):
    if value == 0 or ch.is_npc() or not ch.is_vampire():
        return

    condition = ch.blood
    ch.blood = state_checks.urange(0, condition + value, 48)

    if ch.blood == 0:
        ch.send("You are DYING from lack of blood!\n")
        handler_game.act("$n gets a hungry look in $s eyes.", ch, None, None,
                         merc.TO_ROOM)
        ch.hit -= game_utils.number_range(2, 5)

        if game_utils.number_percent() <= ch.beast and ch.beast > 0:
            ch.vamp_rage()

        if not ch.vampaff.is_set(merc.VAM_FANGS):
            ch.cmd_fangs("")
    elif ch.blood < 10:
        ch.send("You crave blood.\n")

        if game_utils.number_range(1, 1000) <= ch.beast and ch.beast > 0:
            ch.vamp_rage()

        if game_utils.number_percent(
        ) > ch.blood + 75 and not ch.vampaff.is_set(merc.VAM_FANGS):
            ch.cmd_fangs("")
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
def cmd_flee(ch, argument):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

    if ch.is_affected(merc.AFF_WEBBED):
        ch.send("You are unable to move with all this sticky webbing on.\n")
        return

    if not ch.is_npc() and ch.powers[merc.UNI_RAGE] >= 0:
        if ch.is_vampire(
        ) and game_utils.number_percent() <= ch.powers[merc.UNI_RAGE]:
            ch.send("Your inner beast refuses to let you run!\n")
            ch.wait_state(merc.PULSE_VIOLENCE)
            return
        elif ch.is_werewolf(
        ) and game_utils.number_percent() <= ch.powers[merc.UNI_RAGE] * 0.3:
            ch.send("Your rage is too great!\n")
            ch.wait_state(merc.PULSE_VIOLENCE)
            return

    was_in = ch.in_room
    for attempt in range(6):
        door = handler_room.number_door()

        pexit = was_in.exit[door]
        if not pexit or not pexit.to_room or pexit.exit_info.is_set(merc.EX_CLOSED) or \
                (ch.is_npc() and state_checks.is_set(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)):
            continue

        handler_ch.move_char(ch, door)

        now_in = ch.in_room
        if now_in == was_in:
            continue

        ch.in_environment = was_in.instance_id
        handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM)
        ch.in_environment = now_in.instance_id

        if not ch.is_npc():
            ch.send("You flee from combat!  Coward!\n")

        fight.stop_fighting(ch, True)
        return

    ch.send("You were unable to escape!\n")
def spl_acid_breath(sn, level, ch, victim, target):
    if victim.itemaff.is_set(merc.ITEMA_ACIDSHIELD):
        return

    if game_utils.number_percent() < 2 * level and not handler_magic.saves_spell(level, victim):
        for loc in victim.equipped.keys():
            obj = victim.get_eq(loc)
            if not obj or game_utils.number_bits(2) != 0 or obj.flags.spellproof:
                continue

            if obj.item_type == merc.ITEM_ARMOR:
                if obj.value[0] > 0:
                    handler_game.act("$p is pitted and etched!", victim, obj, None, merc.TO_CHAR)
                    victim.armor -= obj.apply_ac()
                    obj.value[0] -= 1
                    obj.cost = 0
                    victim.armor += obj.apply_ac()
            elif obj.item_type == merc.ITEM_CONTAINER:
                handler_game.act("$p fumes and dissolves!", victim, obj, None, merc.TO_CHAR)
                obj.extract()

    hpch = max(10, ch.hit)
    dam = game_utils.number_range(hpch // 16 + 1, hpch // 8)

    if handler_magic.saves_spell(level, victim):
        dam //= 2

    fight.damage(ch, victim, 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_ACID)) else dam, sn)
Exemplo n.º 5
0
def cmd_disarm(ch, argument):
    if not ch.is_npc() and ch.level < const.skill_table["disarm"].skill_level:
        ch.send("You don't know how to disarm opponents.\n")
        return

    if not ch.get_eq("right_hand") and not ch.get_eq("left_hand"):
        ch.send("You must wield a weapon to disarm.\n")
        return

    victim = ch.fighting
    if not victim:
        ch.send("You aren't fighting anyone.\n")
        return

    item = victim.get_eq("right_hand")
    if not item:
        item = victim.get_eq("left_hand")
        if not item:
            ch.send("Your opponent is not wielding a weapon.\n")
            return

    ch.wait_state(const.skill_table["disarm"].beats)

    percent = game_utils.number_percent() + victim.level - ch.level
    if not victim.is_npc() and victim.immune.is_set(merc.IMM_DISARM):
        ch.send("You failed.\n")
    elif ch.is_npc() or percent < ch.learned["disarm"] * 2 // 3:
        fight.disarm(ch, victim)
    else:
        ch.send("You failed.\n")
Exemplo n.º 6
0
def check_hunt(ch):
    in_room = ch.in_room
    if not ch.is_npc() and game_utils.number_percent() > ch.learned["track"]:
        ch.send("You cannot sense any trails from this room.\n")
        ch.hunting = ""
        return

    direction = 0
    dir_list = [merc.DIR_NORTH, merc.DIR_EAST, merc.DIR_SOUTH, merc.DIR_WEST]
    for aa in dir_list:
        if check_track(ch, aa):
            direction = ch.in_room.track_dir[aa]
            break
    else:
        victim = ch.get_char_room(ch.hunting)
        if not victim:
            ch.send("You cannot sense any trails from this room.\n")
            ch.hunting = ""
            return

    if not ch.hunting:
        return

    victim = ch.get_char_room(ch.hunting)
    if victim:
        return

    handler_game.act("$n carefully examines the ground for tracks.", ch, None,
                     None, merc.TO_ROOM)
    ch.move_char(direction)

    if in_room == ch.in_room or victim:
        ch.hunting = ""
Exemplo n.º 7
0
def spl_frost_breath(sn, level, ch, victim, target):
    if victim.itemaff.is_set(merc.ITEMA_ICESHIELD):
        return

    if game_utils.number_percent(
    ) < 2 * level and not handler_magic.saves_spell(level, victim):
        for loc in victim.equipped.keys():
            obj = victim.get_eq(loc)
            if not obj or game_utils.number_bits(
                    2) != 0 or obj.flags.spellproof:
                continue

            if obj.item_type == [
                    merc.ITEM_CONTAINER, merc.ITEM_DRINK_CON, merc.ITEM_POTION
            ]:
                handler_game.act("$p freezes and shatters!", victim, obj, None,
                                 merc.TO_CHAR)
                obj.extract()

    hpch = max(10, ch.hit)
    dam = game_utils.number_range(hpch // 16 + 1, hpch // 8)

    if handler_magic.saves_spell(level, victim):
        dam //= 2

    fight.damage(
        ch, victim, dam * 0.5 if
        (not victim.is_npc() and victim.is_vampire()) else 0 if
        (not victim.is_npc() and victim.immune.is_set(merc.IMM_COLD)) else 1,
        sn)
Exemplo n.º 8
0
def spl_fire_breath(sn, level, ch, victim, target):
    if victim.itemaff.is_set(merc.ITEMA_FIRESHIELD):
        return

    if game_utils.number_percent() < 2 * level and not handler_magic.saves_spell(level, victim):
        for loc in victim.equipped.keys():
            obj = victim.get_eq(loc)
            if not obj or game_utils.number_bits(2) != 0 or obj.flags.spellproof:
                continue

            item_list = [(merc.ITEM_CONTAINER, "$p ignites and burns!"), (merc.ITEM_POTION, "$p bubbles and boils!"),
                         (merc.ITEM_SCROLL, "$p crackles and burns!"), (merc.ITEM_STAFF, "$p smokes and chars!"),
                         (merc.ITEM_WAND, "$p sparks and sputters!"), (merc.ITEM_FOOD, "$p blackens and crisps!"),
                         (merc.ITEM_PILL, "$p melts and drips!")]
            for (aa, bb) in item_list:
                if obj.item_type == aa:
                    msg = bb
                    break
            else:
                continue

            handler_game.act(msg, victim, obj, None, merc.TO_CHAR)
            obj.extract()

    hpch = max(10, ch.hit)
    dam = game_utils.number_range(hpch // 16 + 1, hpch // 8)

    if handler_magic.saves_spell(level, victim):
        dam //= 2

    fight.damage(ch, victim, dam * 2 if (not victim.is_npc() and victim.is_vampire()) else 0 if (not victim.is_npc() and
                                                                                                 victim.immune.is_set(merc.IMM_HEAT)) else 1, sn)
Exemplo n.º 9
0
def saves_spell(level, victim):
    if not victim.is_npc():
        tsave = sum([victim.spl[0], victim.spl[1], victim.spl[2], victim.spl[3], victim.spl[4]]) * 0.05
        save = 50 + (tsave - level - victim.saving_throw) * 5
    else:
        save = 50 + (victim.level - level - victim.saving_throw) * 5
    save = state_checks.urange(15, save, 85)
    return game_utils.number_percent() < save
Exemplo n.º 10
0
def cmd_sneak(ch, argument):
    ch.send("You attempt to move silently.\n")
    ch.affect_strip("sneak")

    if ch.is_affected(merc.AFF_SNEAK):
        return

    if ch.is_npc() or game_utils.number_percent() < ch.learned["sneak"]:
        aff = handler_game.AffectData()
        aff.type = "sneak"
        aff.duration = ch.level
        aff.location = merc.APPLY_NONE
        aff.bitvector = merc.AFF_SNEAK
        ch.affect_add(aff)
Exemplo n.º 11
0
def cmd_track(ch, argument):
    if not ch.is_npc() and game_utils.number_percent() > ch.learned["track"]:
        ch.send("You cannot sense any trails from this room.\n")
        return

    found = False
    for direction in range(merc.MAX_DIR):
        if check_track(ch, direction):
            found = True

    if not found:
        ch.send("You cannot sense any trails from this room.\n")
        return

    handler_game.act("$n carefully examines the ground for tracks.", ch, None, None, merc.TO_ROOM)
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
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")
Exemplo n.º 14
0
def cmd_berserk(ch, argument):
    if ch.is_npc():
        return

    if ch.level < const.skill_table["berserk"].skill_level:
        ch.send("You are not wild enough to go berserk.\n")
        return

    ch.wait_state(const.skill_table["berserk"].beats)

    if game_utils.number_percent() > ch.learned["berserk"]:
        handler_game.act("You rant and rave, but nothing much happens.", ch, None, None, merc.TO_CHAR)
        handler_game.act("$n gets a wild look in $s eyes, but nothing much happens.", ch, None, None, merc.TO_ROOM)
        return

    handler_game.act("You go BERSERK!", ch, None, None, merc.TO_CHAR)
    handler_game.act("$n goes BERSERK!", ch, None, None, merc.TO_ROOM)

    number_hit = 0
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]

        if number_hit > 4:
            continue

        if not vch.is_npc() and vch.chobj:
            continue

        if ch == vch or not ch.can_see(vch):
            continue

        mount = ch.mount
        if mount and mount == vch:
            continue

        fight.multi_hit(ch, vch, merc.TYPE_UNDEFINED)
        number_hit += 1

    ch.beastlike()
Exemplo n.º 15
0
def cmd_hide(ch, argument):
    ch.send("You attempt to hide.\n")
    ch.affected_by.rem_bit(merc.AFF_HIDE)

    if ch.is_npc() or game_utils.number_percent() < ch.learned["hide"]:
        ch.affected_by.set_bit(merc.AFF_HIDE)
Exemplo n.º 16
0
def cmd_cast(ch, argument):
    # Switched NPC's can cast spells, but others can't.
    if ch.is_npc() and not ch.desc:
        return

    # Polymorphed players cannot cast spells
    if not ch.is_npc() and ch.is_affected(
            merc.AFF_POLYMORPH) and not ch.vampaff.is_set(merc.VAM_DISGUISED):
        if not ch.is_obj():
            ch.send("You cannot cast spells in this form.\n")
            return

    if ch.itemaff.is_set(merc.ITEMA_REFLECT):
        ch.send("You are unable to focus your spell.\n")
        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 not sn.spell_fun or (not ch.is_npc()
                                      and ch.level < sn.skill_level
                                      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:
        if not ch.is_npc() and not ch.is_vampire() and ch.vampaff.is_set(
                merc.VAM_CELERITY):
            if ch.move < 25:
                ch.send("You can't concentrate enough.\n")
                return

            ch.move -= 25
        else:
            if ch.move < 50:
                ch.send("You can't concentrate enough.\n")
                return

            ch.move -= 50

    mana = 0 if ch.is_npc() else max(
        sn.min_mana, 100 // (2 + (ch.level * 12) - sn.skill_level))

    if not ch.is_npc() and ch.special.is_set(merc.SPC_WOLFMAN):
        if ch.powers[merc.WPOWER_OWL] < 4:
            mana *= 2

    # Locate targets.
    victim = 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.not_here(arg2)
                return

        if ch == victim:
            ch.send("Cast this on yourself? Ok...\n")

        if victim.itemaff.is_set(merc.ITEMA_REFLECT):
            ch.send("You are unable to focus your spell upon them.\n")
            return

        if not victim.is_npc() and (not ch.can_pk()
                                    or not victim.can_pk()) and victim != ch:
            ch.send("You are unable to affect them.\n")
            return

        if not ch.is_npc():
            if ch.is_affected(merc.AFF_CHARM) and instance.characters[
                    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.not_here(handler_magic.target_name)
                return

        if victim.itemaff.is_set(merc.ITEMA_REFLECT):
            ch.send("You are unable to focus your spell upon them.\n")
            return

        vo = victim
        target = merc.TARGET_CHAR
    elif sn.target == merc.TAR_CHAR_SELF:
        if arg2 and game_utils.is_name(handler_magic.target_name, ch.name):
            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)
        if not obj:
            ch.send("You are not carrying that.\n")
            return

        vo = obj
        target = merc.TARGET_ITEM
    else:
        comm.notify("cmd_cast: bad target for sn {}".format(sn),
                    merc.CONSOLE_ERROR)
        return

    if not ch.is_npc() and ch.mana < mana:
        ch.send("You don't have enough mana.\n")
        return

    if not game_utils.str_cmp(sn.name, "ventriloquate"):
        handler_magic.say_spell(ch, sn)

    ch.wait_state(sn.beats)

    if not ch.is_npc() and game_utils.number_percent() > ch.learned[sn.name]:
        ch.send("You lost your concentration.\n")
        ch.mana -= mana // 2
        ch.improve_spl(sn.target)
    else:
        ch.mana -= mana

        if ch.is_npc():
            sn.spell_fun(sn.name, int(ch.level), ch, vo, target)
        else:
            sn.spell_fun(sn.name, int(ch.spl[sn.target] * 0.25), ch, vo,
                         target)
            ch.improve_spl(sn.target)

    if sn.target == merc.TAR_CHAR_OFFENSIVE and victim != ch and (
            victim.master and instance.characters[victim.master] != ch):
        for vch_id in ch.in_room.people[:]:
            vch = instance.characters[vch_id]

            if victim == vch and not victim.fighting:
                fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED)
                break
Exemplo n.º 17
0
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)
Exemplo n.º 18
0
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())
Exemplo n.º 19
0
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)
Exemplo n.º 20
0
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)
Exemplo n.º 21
0
def cmd_kick(ch, argument):
    if not ch.is_npc() and ch.level < const.skill_table["kick"].skill_level:
        ch.send("First you should learn to kick.\n")
        return

    victim = ch.fighting
    if not victim:
        ch.send("You aren't fighting anyone.\n")
        return

    ch.wait_state(const.skill_table["kick"].beats)

    if ch.is_npc() or game_utils.number_percent() < ch.learned["kick"]:
        dam = game_utils.number_range(1, 4)
    elif not victim.is_npc() and victim.immune.is_set(merc.IMM_KICK):
        fight.damage(ch, victim, 0, "kick")
    else:
        fight.damage(ch, victim, 0, "kick")
        return

    dam = ch.damroll

    if dam == 0:
        dam = 1

    if not victim.is_awake():
        dam *= 2

    if not ch.is_npc() and ch.is_vampire() and ch.vampaff.is_set(
            merc.VAM_POTENCE):
        dam *= 1.5
    elif not ch.is_npc() and (ch.special.is_set(merc.SPC_CHAMPION)
                              or ch.is_demon()) and ch.dempower.is_set(
                                  merc.DEM_MIGHT):
        dam *= 1.5

    if not victim.is_npc() and victim.is_werewolf():
        if victim.special.is_set(merc.SPC_WOLFMAN):
            dam *= 0.5

        if victim.powers[merc.WPOWER_BOAR] > 2:
            dam *= 0.5

        boots = ch.get_eq("feet")
        if boots and boots.flags.silver:
            dam *= 2

    # Vampires should be tougher at night and weaker during the day.
    if not ch.is_npc() and ch.is_vampire():
        if handler_game.weather_info.sunlight == merc.SUN_LIGHT and dam > 1:
            dam //= 1.5
        elif handler_game.weather_info.sunlight == merc.SUN_DARK:
            dam *= 1.5

    if not ch.is_npc():
        dam = dam + (dam * ((ch.wpn[merc.WPN_UNARMED] + 1) // 100))

        stance = ch.stance[0]
        if ch.stance[0] == merc.STANCE_NORMAL:
            dam *= 1.25
        else:
            dam = fight.dambonus(ch, victim, dam, stance)

    if dam <= 0:
        dam = 1

    fight.damage(ch, victim, dam, "kick")
Exemplo n.º 22
0
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
Exemplo n.º 23
0
def cmd_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.not_here(arg2)
        return

    if ch == victim:
        ch.not_self()
        return

    if victim.is_immortal():
        ch.not_imm()
        return

    ch.wait_state(const.skill_table["steal"].beats)
    percent = game_utils.number_percent() + (10 if victim.is_awake() else -50)

    if (ch.level + game_utils.number_range(1, 20) < victim.level) or (not ch.is_npc() and not victim.is_npc() and ch.level < 3) or \
            (not ch.is_npc() and not victim.is_npc() and victim.level < 3) or (victim.position == merc.POS_FIGHTING) or \
            (not victim.is_npc() and victim.immune.is_set(merc.IMM_STEAL)) or (not victim.is_npc() and victim.is_immortal()) or \
            (not ch.is_npc() and percent > ch.learned["steal"]):
        # Failure.
        ch.send("Oops.\n")
        handler_game.act("$n tried to steal from you.", ch, None, victim,
                         merc.TO_VICT)
        handler_game.act("$n tried to steal from $N.", ch, None, victim,
                         merc.TO_NOTVICT)
        victim.cmd_shout("{} is a bloody thief!".format(ch.name))

        if not ch.is_npc():
            if victim.is_npc():
                fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED)
            else:
                ch.save(force=True)
        return

    if game_utils.str_cmp(arg1, ["coin", "coins", "gold"]):
        amount = victim.gold * game_utils.number_range(1, 10) // 100
        if amount <= 0:
            ch.send("You couldn't get any gold.\n")
            return

        ch.gold += amount
        victim.gold -= amount
        ch.send("Bingo!  You got {:,} gold coins.\n".format(amount))
        ch.save(force=True)
        victim.save(force=True)
        return

    item = victim.get_item_carry(arg1)
    if not item:
        ch.send("You can't find it.\n")
        return

    if not victim.can_drop_item(
            item) or item.flags.loyal or item.flags.inventory:
        ch.send("You can't pry it away.\n")
        return

    if ch.carry_number + 1 > ch.can_carry_n():
        ch.send("You have your hands full.\n")
        return

    if ch.carry_weight + item.get_obj_weight() > ch.can_carry_w():
        ch.send("You can't carry that much weight.\n")
        return

    victim.get(item)
    ch.put(item)
    ch.send("You got it!\n")
    ch.save(force=True)
    victim.save(force=True)