コード例 #1
0
def do_disarm(ch, argument):
    hth = 0
    chance = ch.get_skill('disarm')
    if chance == 0:
        ch.send("You don't know how to disarm opponents.\n")
        return
    hth = ch.get_skill('hand to hand')
    if not ch.get_eq('main_hand') \
            and hth == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_DISARM)):
        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('main_hand')
    if not item:
        ch.send("Your opponent is not wielding a weapon.\n")
        return

    # find weapon skills
    ch_weapon = ch.get_weapon_skill(ch.get_weapon_sn())
    vict_weapon = victim.get_weapon_skill(victim.get_weapon_sn())
    ch_vict_weapon = ch.get_weapon_skill(victim.get_weapon_sn())

    # modifiers

    # skill
    if not ch.get_eq('main_hand'):
        chance = chance * hth // 150
    else:
        chance = chance * ch_weapon // 100

    chance += (ch_vict_weapon // 2 - vict_weapon) // 2

    # dex vs. strength
    chance += ch.stat(merc.STAT_DEX)
    chance -= 2 * victim.stat(merc.STAT_STR)

    # level
    chance += (ch.level - victim.level) * 2

    # and now the attack
    if random.randint(1, 99) < chance:
        state_checks.WAIT_STATE(ch, const.skill_table['disarm'].beats)
        fight.disarm(ch, victim)
        if ch.is_pc():
            ch.check_improve('disarm', True, 1)
    else:
        state_checks.WAIT_STATE(ch, const.skill_table['disarm'].beats)
        handler_game.act("You fail to disarm $N.", ch, None, victim,
                         merc.TO_CHAR)
        handler_game.act("$n tries to disarm you, but fails.", ch, None,
                         victim, merc.TO_VICT)
        handler_game.act("$n tries to disarm $N, but fails.", ch, None, victim,
                         merc.TO_NOTVICT)
        if ch.is_pc():
            ch.check_improve('disarm', False, 1)
    fight.check_killer(ch, victim)
    return
コード例 #2
0
ファイル: do_password.py プロジェクト: totalgit/PyRom
def do_password(ch, argument):
    if ch.is_npc():
        return

    # Can't use read_word here because it smashes case.
    # So we just steal all its code.  Bleagh.
    # -- It actually doesn't now because it loads areas too. Davion.
    argument, arg1 = game_utils.read_word(argument, False)
    argument, arg2 = game_utils.read_word(argument, False)

    if not arg1 or not arg2:
        ch.send("Syntax: password <old> <new>.\n")
        return

    if settings.ENCRYPT_PASSWORD:
        # Had to add .encode() for unicode text input.
        arg1 = hashlib.sha512(arg1.encode()).hexdigest()
        arg2 = hashlib.sha512(arg2.encode()).hexdigest()

    if arg1 != ch.pwd:
        state_checks.WAIT_STATE(ch, 40)
        ch.send("Wrong password.  Wait 10 seconds.\n")
        return
    if len(arg2) < 5:
        ch.send("New password must be at least five characters long.\n")
        return

        # No tilde allowed because of player file format.
        # Also now not true. Davion

    ch.pwd = arg2
    ch.save()
    ch.send("Ok.\n")
    return
コード例 #3
0
def do_save(ch, argument):
    if ch.is_npc():
        return
    ch.save()
    #save.legacy_save_char_obj(ch)
    ch.send("Saving. Remember that ROM has automatic saving now.\n")
    state_checks.WAIT_STATE(ch, 4 * merc.PULSE_VIOLENCE)
    return
コード例 #4
0
def do_brandish(ch, argument):
    staff = ch.get_eq('held')
    if not staff:
        ch.send("You hold nothing in your hand.\n")
        return
    if staff.item_type != merc.ITEM_STAFF:
        ch.send("You can brandish only with a staff.\n")
        return
    sn = staff.value[3]
    if not sn or not const.skill_table[sn].spell_fun:
        logger.error("BUG: Do_brandish: bad sn %s.", sn)
        return
    state_checks.WAIT_STATE(ch, 2 * merc.PULSE_VIOLENCE)
    if staff.value[2] > 0:
        handler_game.act("$n brandishes $p.", ch, staff, None, merc.TO_ROOM)
        handler_game.act("You brandish $p.", ch, staff, None, merc.TO_CHAR)
        if ch.level < staff.level or random.randint(
                1, 99) >= 20 + ch.get_skill("staves") * 4 / 5:
            handler_game.act("You fail to invoke $p.", ch, staff, None,
                             merc.TO_CHAR)
            handler_game.act("...and nothing happens.", ch, None, None,
                             merc.TO_ROOM)
            if ch.is_pc():
                ch.check_improve("staves", False, 2)
        else:
            for vch_id in ch.in_room.people[:]:
                vch = instance.characters[vch_id]
                target = const.skill_table[sn].target
                if target == merc.TAR_IGNORE:
                    if vch != ch:
                        continue
                elif target == merc.TAR_CHAR_OFFENSIVE:
                    if vch.is_npc() if ch.is_npc() else not vch.is_npc():
                        continue
                elif target == merc.TAR_CHAR_DEFENSIVE:
                    if not vch.is_npc() if ch.is_npc() else vch.is_npc():
                        continue
                elif target == merc.TAR_CHAR_SELF:
                    if vch != ch:
                        continue
                else:
                    logger.error("BUG: Do_brandish: bad target for sn %s.", sn)
                    return
                handler_magic.obj_cast_spell(staff.value[3], staff.value[0],
                                             ch, vch, None)
                if ch.is_pc():
                    ch.check_improve("staves", True, 2)
    staff.value[2] -= 1
    if staff.value[2] <= 0:
        handler_game.act("$n's $p blazes bright and is gone.", ch, staff, None,
                         merc.TO_ROOM)
        handler_game.act("Your $p blazes bright and is gone.", ch, staff, None,
                         merc.TO_CHAR)
        staff.extract()
コード例 #5
0
def do_order(ch, argument):
    argument, arg = game_utils.read_word(argument)
    remainder, arg2 = game_utils.read_word(argument)

    if arg2 == "delete":
        ch.send("That will NOT be done.\n")
        return
    if not arg or not argument:
        ch.send("Order whom to do what?\n")
        return

    if ch.is_affected(merc.AFF_CHARM):
        ch.send("You feel like taking, not giving, orders.\n")
        return
    victim = None
    if arg == "all":
        fAll = True
        victim = None
    else:
        fAll = False
        victim = ch.get_char_room(arg)
        if not victim:
            ch.send("They aren't here.\n")
            return
        if victim == ch:
            ch.send("Aye aye, right away!\n")
            return
        if not victim.is_affected( merc.AFF_CHARM) or victim.master != ch \
                or (state_checks.IS_IMMORTAL(victim) and victim.trust >= ch.trust):
            ch.send("Do it yourself!\n")
            return
    found = False
    for och_id in ch.in_room.people[:]:
        och = instance.characters[och_id]
        if state_checks.IS_AFFECTED(och, merc.AFF_CHARM) \
                and och.master == ch \
                and (fAll or och == victim):
            found = True
            handler_game.act("$n orders you to '%s'." % argument, ch, None, och, merc.TO_VICT)
            och.interpret(argument)

    if found:
        state_checks.WAIT_STATE(ch, merc.PULSE_VIOLENCE)
        ch.send("Ok.\n")
    else:
        ch.send("You have no followers here.\n")
    return
コード例 #6
0
def do_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.send("They aren't here.\n")
        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 state_checks.IS_NPC(fch) and not ch.is_same_group(victim):
        ch.send("Kill stealing is not permitted.\n")
        return
    state_checks.WAIT_STATE(ch, const.skill_table['rescue'].beats)
    if random.randint(1, 99) > ch.get_skill('rescue'):
        ch.send("You fail the rescue.\n")
        if ch.is_pc():
            ch.check_improve('rescue', False, 1)
        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)
    if ch.is_pc():
        ch.check_improve('rescue', True, 1)

    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)
    return
コード例 #7
0
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
コード例 #8
0
ファイル: do_murder.py プロジェクト: totalgit/PyRom
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
コード例 #9
0
ファイル: do_shout.py プロジェクト: totalgit/PyRom
def do_shout(ch, argument):
    if not argument:
        if ch.comm.is_set(merc.COMM_SHOUTSOFF):
            ch.send("You can hear shouts again.\n")
            ch.comm.rem_bit(merc.COMM_SHOUTSOFF)
        else:
            ch.send("You will no longer hear shouts.\n")
            ch.comm.set_bit(merc.COMM_SHOUTSOFF)
        return
    if ch.comm.is_set(merc.COMM_NOSHOUT):
        ch.send("You can't shout.\n")
        return
    ch.comm.rem_bit(merc.COMM_SHOUTSOFF)
    state_checks.WAIT_STATE(ch, 12)
    handler_game.act("You shout '$T'", ch, None, argument, merc.TO_CHAR)
    for d in merc.descriptor_list:
        victim = handler_ch.CH(d)
        if d.is_connected(nanny.con_playing) and d.character != ch \
                and not victim.comm.is_set(merc.COMM_SHOUTSOFF) and not state_checks.IS_SET(victim.comm,
                                                                                                          merc.COMM_QUIET):
            handler_game.act("$n shouts '$t'", ch, argument, d.character,
                             merc.TO_VICT)
コード例 #10
0
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
コード例 #11
0
ファイル: do_kick.py プロジェクト: totalgit/PyRom
def do_kick(ch, argument):
    if not ch.is_npc() and ch.level < const.skill_table['kick'].skill_level[
            ch.guild.name]:
        ch.send("You better leave the martial arts to fighters.\n")
        return
    if ch.is_npc() and not ch.off_flags.is_set(merc.OFF_KICK):
        return
    victim = ch.fighting
    if not victim:
        ch.send("You aren't fighting anyone.\n")
        return

    state_checks.WAIT_STATE(ch, const.skill_table['kick'].beats)
    if ch.get_skill('kick') > random.randint(1, 99):
        fight.damage(ch, victim, random.randint(1, ch.level), 'kick',
                     merc.DAM_BASH, True)
        if ch.is_pc():
            ch.check_improve('kick', True, 1)
    else:
        fight.damage(ch, victim, 0, 'kick', merc.DAM_BASH, True)
        if ch.is_pc():
            ch.check_improve('kick', False, 1)
    fight.check_killer(ch, victim)
    return
コード例 #12
0
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)
コード例 #13
0
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)
コード例 #14
0
ファイル: do_pick.py プロジェクト: totalgit/PyRom
def do_pick(self, argument):
    ch = self
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Pick what?\n")
        return

    state_checks.WAIT_STATE(ch, const.skill_table["pick lock"].beats)

    # look for guards
    for gch_id in ch.in_room.people:
        gch = instance.characters[gch_id]
        if state_checks.IS_NPC(gch) and state_checks.IS_AWAKE(gch) and ch.level + 5 < gch.level:
            handler_game.act("$N is standing too close to the lock.", ch, None, gch, merc.TO_CHAR)
            return
        if not ch.is_npc() and random.randint(1, 99) > ch.get_skill("pick lock"):
            ch.send("You failed.\n")
            if ch.is_pc():
                ch.check_improve( "pick lock", False, 2)
            return
        obj = ch.get_item_here(arg)
        if obj:
            # portal stuff
            if obj.item_type == merc.ITEM_PORTAL:
                if not state_checks.IS_SET(obj.value[1], merc.EX_ISDOOR):
                    ch.send("You can't do that.\n")
                    return
                if not state_checks.IS_SET(obj.value[1], merc.EX_CLOSED):
                    ch.send("It's not closed.\n")
                    return
                if obj.value[4] < 0:
                    ch.send("It can't be unlocked.\n")
                    return
                if state_checks.IS_SET(obj.value[1], merc.EX_PICKPROOF):
                    ch.send("You failed.\n")
                    return
                state_checks.REMOVE_BIT(obj.value[1], merc.EX_LOCKED)
                handler_game.act("You pick the lock on $p.", ch, obj, None, merc.TO_CHAR)
                handler_game.act("$n picks the lock on $p.", ch, obj, None, merc.TO_ROOM)
                if ch.is_pc():
                    ch.check_improve( "pick lock", True, 2)
                return


                # 'pick object'
            if obj.item_type != merc.ITEM_CONTAINER:
                ch.send("That's not a container.\n")
                return
            if not state_checks.IS_SET(obj.value[1], merc.CONT_CLOSED):
                ch.send("It's not closed.\n")
                return
            if obj.value[2] < 0:
                ch.send("It can't be unlocked.\n")
                return
            if not state_checks.IS_SET(obj.value[1], merc.CONT_LOCKED):
                ch.send("It's already unlocked.\n")
                return
            if state_checks.IS_SET(obj.value[1], merc.CONT_PICKPROOF):
                ch.send("You failed.\n")
                return

            state_checks.REMOVE_BIT(obj.value[1], merc.CONT_LOCKED)
            handler_game.act("You pick the lock on $p.", ch, obj, None, merc.TO_CHAR)
            handler_game.act("$n picks the lock on $p.", ch, obj, None, merc.TO_ROOM)
            if ch.is_pc():
                ch.check_improve( "pick lock", True, 2)
            return
        door = handler_room.find_door(ch, arg)
        if door >= 0:
            # 'pick door'
            pexit = ch.in_room.exit[door]
            if not pexit.exit_info.is_set(merc.EX_CLOSED) and not ch.is_immortal():
                ch.send("It's not closed.\n")
                return
            if pexit.key < 0 and not ch.is_immortal():
                ch.send("It can't be picked.\n")
                return
            if not pexit.exit_info.is_set(merc.EX_LOCKED):
                ch.send("It's already unlocked.\n")
                return
            if pexit.exit_info.is_set(merc.EX_PICKPROOF) and not ch.is_immortal():
                ch.send("You failed.\n")
                return
            pexit.exit_info.rem_bit(merc.EX_LOCKED)
            ch.send("*Click*\n")
            handler_game.act("$n picks the $d.", ch, None, pexit.keyword, merc.TO_ROOM)
            if ch.is_pc():
                ch.check_improve( "pick_lock", True, 2)

            # unlock the other side
            to_room = pexit.to_room
            if to_room and to_room.exit[merc.rev_dir[door]] != 0 \
                    and to_room.exit[merc.rev_dir[door]].to_room == ch.in_room:
                to_room.exit[merc.rev_dir[door]].exit_info.rem_bit(merc.EX_LOCKED)
コード例 #15
0
def do_berserk(ch, argument):
    chance = ch.get_skill('berserk')
    if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_BERSERK)) \
            or (not ch.is_npc() and ch.level < const.skill_table['berserk'].skill_level[ch.guild.name]):
        ch.send("You turn red in the face, but nothing happens.\n")
        return

    if ch.is_affected(merc.AFF_BERSERK) or state_checks.is_affected(
            ch, 'berserk') or state_checks.is_affected(ch, "frenzy"):
        ch.send("You get a little madder.\n")
        return
    if ch.is_affected(merc.AFF_CALM):
        ch.send("You're feeling to mellow to berserk.\n")
        return
    if ch.mana < 50:
        ch.send("You can't get up enough energy.\n")
        return
    # modifiers
    # fighting
    if ch.position == merc.POS_FIGHTING:
        chance += 10

    # damage -- below 50% of hp helps, above hurts
    hp_percent = 100 * ch.hit // ch.max_hit
    chance += 25 - hp_percent // 2

    if random.randint(1, 99) < chance:
        state_checks.WAIT_STATE(ch, merc.PULSE_VIOLENCE)
        ch.mana -= 50
        ch.move //= 2
        # heal a little damage
        ch.hit += ch.level * 2
        ch.hit = min(ch.hit, ch.max_hit)
        ch.send("Your pulse races as you are consumed by rage!\n")
        handler_game.act("$n gets a wild look in $s eyes.", ch, None, None,
                         merc.TO_ROOM)
        if not ch.is_npc():
            if ch.is_pc():
                ch.check_improve('berserk', True, 2)
        af = handler_game.AFFECT_DATA()
        af.where = merc.TO_AFFECTS
        af.type = 'berserk'
        af.level = ch.level
        af.duration = game_utils.number_fuzzy(ch.level // 8)
        af.modifier = max(1, ch.level // 5)
        af.bitvector = merc.AFF_BERSERK

        af.location = merc.APPLY_HITROLL
        ch.affect_add(af)

        af.location = merc.APPLY_DAMROLL
        ch.affect_add(af)

        af.modifier = max(10, 10 * (ch.level // 5))
        af.location = merc.APPLY_AC
        ch.affect_add(af)
    else:
        state_checks.WAIT_STATE(ch, 3 * merc.PULSE_VIOLENCE)
        ch.mana -= 25
        ch.move //= 2

        ch.send("Your pulse speeds up, but nothing happens.\n")
        if not ch.is_npc():
            if ch.is_pc():
                ch.check_improve('berserk', False, 2)
コード例 #16
0
ファイル: do_bash.py プロジェクト: totalgit/PyRom
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)
コード例 #17
0
ファイル: do_steal.py プロジェクト: totalgit/PyRom
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
コード例 #18
0
ファイル: do_cast.py プロジェクト: totalgit/PyRom
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