Example #1
0
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
Example #2
0
def spec_executioner(ch):
    if not ch.is_awake() or ch.fighting is not None:
        return False

    crime = ""
    victim = None
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]
        if not vch.is_npc() and vch.act.is_set(
                merc.PLR_KILLER) and ch.can_see(vch):
            victim = vch
            crime = "KILLER"

        if not vch.is_npc() and vch.act.is_set(
                merc.PLR_THIEF) and ch.can_see(vch):
            victim = vch
            crime = "THIEF"

    if victim is None:
        return False

    ch.comm.rem_bit(merc.COMM_NOSHOUT)
    ch.do_yell("%s is a %s!  PROTECT THE INNOCENT!  MORE BLOOOOD!!!" %
               (victim.name, crime))
    fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
    return True
Example #3
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
def obj_cast_spell(sn, level, ch, victim, obj):
    global target_name

    target = merc.TARGET_NONE
    if not sn:
        return

    if sn not in const.skill_table or not const.skill_table[sn].spell_fun:
        comm.notify("obj_cast_spell: bad sn {}".format(sn), merc.CONSOLE_ERROR)
        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

        vo = victim
        target = merc.TARGET_CHAR
    elif sn.target == merc.TAR_CHAR_DEFENSIVE:
        if not victim:
            victim = ch

        vo = victim
        target = merc.TARGET_CHAR
    elif sn.target == merc.TAR_CHAR_SELF:
        vo = ch
        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
    else:
        comm.notify("obj_cast_spell: bad target for sn {}".format(sn.name),
                    merc.CONSOLE_ERROR)
        return

    target_name = ""
    sn.spell_fun(sn, level, ch, vo, target)

    if sn.target == merc.TAR_CHAR_OFFENSIVE and victim != ch and instance.characters[
            victim.master] != ch:
        for vch in ch.in_room.people[:]:
            if victim == vch and not victim.fighting:
                fight.multi_hit(victim, ch, merc.TYPE_UNDEFINED)
                break
Example #5
0
def spec_patrolman(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
    victim = None
    # look for a fight in the room */
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]
        if vch == ch:
            continue

        if vch.fighting is not None:  # break it up! */
            if random.randint(0, count) == 0:
                victim = vch if (
                    vch.level > vch.fighting.level) else vch.fighting
                count += 1

    if victim is None or (victim.is_npc() and victim.spec_fun == ch.spec_fun):
        return False
    neck = ch.get_eq('neck')
    collar = ch.get_eq('collar')
    if (neck and neck.vnum == merc.OBJ_VNUM_WHISTLE) \
            or (collar and collar.vnum == merc.OBJ_VNUM_WHISTLE):
        handler_game.act("You blow down hard on $p.", ch,
                         instance.items[neck.instance_id], None, merc.TO_CHAR)
        handler_game.act("$n blows on $p, ***WHEEEEEEEEEEEET***", ch,
                         instance.items[neck.instance_id], None, merc.TO_ROOM)

        for vch in instance.characters.values():
            if vch.in_room is None:
                continue
            if vch.in_room != ch.in_room and instance.area_templates[instance.rooms[vch.in_room].area] \
                    == instance.area_templates[instance.room_templates[ch.in_room].area]:
                vch.send("You hear a shrill whistling sound.\n")

    messages = [
        "$n yells 'All roit! All roit! break it up!'",
        "$n says 'Society's to blame, but what's a bloke to do?'",
        "$n mumbles 'bloody kids will be the death of us all.'",
        "$n shouts 'Stop that! Stop that!' and attacks.",
        "$n pulls out his billy and goes to work.",
        "$n sighs in resignation and proceeds to break up the fight.",
        "$n says 'Settle down, you hooligans!'"
    ]
    message = random.choice(messages)
    handler_game.act(message, ch, None, None, merc.TO_ALL)
    fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
    return True
Example #6
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")
Example #7
0
def aggr_update():
    for wch in instance.characters.values():
        if wch.is_npc() \
                or wch.level >= merc.LEVEL_IMMORTAL \
                or wch.in_room is None \
                or wch.in_area.empty:
            continue

        for ch_id in wch.in_room.people[:]:
            ch = instance.characters[ch_id]
            if not ch.is_npc() \
                    or not ch.act.is_set(merc.ACT_AGGRESSIVE) \
                    or state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_SAFE) \
                    or ch.is_affected(merc.AFF_CALM) \
                    or ch.fighting is not None \
                    or ch.is_affected(merc.AFF_CHARM) \
                    or not ch.is_awake() \
                    or (ch.act.is_set(merc.ACT_WIMPY) and wch.is_awake()) \
                    or not ch.can_see(wch) \
                    or random.randint(0, 1) == 0:
                continue

            #
            # * Ok we have a 'wch' player character and a 'ch' npc aggressor.
            # * Now make the aggressor fight a RANDOM pc victim in the room,
            # *   giving each 'vch' an equal chance of selection.
            count = 0
            victim = None
            for vch_id in wch.in_room.people[:]:
                vch = instance.characters[vch_id]
                if not vch.is_npc() \
                        and vch.level < merc.LEVEL_IMMORTAL \
                        and ch.level >= vch.level - 5 \
                        and (not ch.act.is_set(merc.ACT_WIMPY) or not vch.is_awake()) \
                        and ch.can_see(vch):
                    if random.randint(0, count) == 0:
                        victim = vch
                    count += 1

            if not victim:
                continue

            fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
Example #8
0
def spec_patrolman(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
    victim = None
    # look for a fight in the room */
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]
        if vch == ch:
            continue

        if vch.fighting is not None:  # break it up! */
            if random.randint(0, count) == 0:
                victim = vch if (vch.level > vch.fighting.level) else vch.fighting
                count += 1

    if victim is None or (victim.is_npc() and victim.spec_fun == ch.spec_fun):
        return False
    neck = ch.get_eq('neck')
    collar = ch.get_eq('collar')
    if (neck and neck.vnum == merc.OBJ_VNUM_WHISTLE) \
            or (collar and collar.vnum == merc.OBJ_VNUM_WHISTLE):
        handler_game.act("You blow down hard on $p.", ch, instance.items[neck.instance_id], None, merc.TO_CHAR)
        handler_game.act("$n blows on $p, ***WHEEEEEEEEEEEET***", ch, instance.items[neck.instance_id], None, merc.TO_ROOM)

        for vch in instance.characters.values():
            if vch.in_room is None:
                continue
            if vch.in_room != ch.in_room and instance.area_templates[instance.rooms[vch.in_room].area] \
                    == instance.area_templates[instance.room_templates[ch.in_room].area]:
                vch.send("You hear a shrill whistling sound.\n")

    messages = ["$n yells 'All roit! All roit! break it up!'",
                "$n says 'Society's to blame, but what's a bloke to do?'",
                "$n mumbles 'bloody kids will be the death of us all.'",
                "$n shouts 'Stop that! Stop that!' and attacks.",
                "$n pulls out his billy and goes to work.",
                "$n sighs in resignation and proceeds to break up the fight.",
                "$n says 'Settle down, you hooligans!'"]
    message = random.choice(messages)
    handler_game.act(message, ch, None, None, merc.TO_ALL)
    fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
    return True
Example #9
0
def aggr_update():
    for wch in instance.characters.values():
        if wch.is_npc() \
                or wch.level >= merc.LEVEL_IMMORTAL \
                or wch.in_room is None \
                or wch.in_area.empty:
            continue

        for ch_id in wch.in_room.people[:]:
            ch = instance.characters[ch_id]
            if not ch.is_npc() \
                    or not ch.act.is_set(merc.ACT_AGGRESSIVE) \
                    or state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_SAFE) \
                    or ch.is_affected(merc.AFF_CALM) \
                    or ch.fighting is not None \
                    or ch.is_affected(merc.AFF_CHARM) \
                    or not ch.is_awake() \
                    or (ch.act.is_set(merc.ACT_WIMPY) and wch.is_awake()) \
                    or not ch.can_see(wch) \
                    or random.randint(0, 1) == 0:
                continue

            #
            # * Ok we have a 'wch' player character and a 'ch' npc aggressor.
            # * Now make the aggressor fight a RANDOM pc victim in the room,
            # *   giving each 'vch' an equal chance of selection.
            count = 0
            victim = None
            for vch_id in wch.in_room.people[:]:
                vch = instance.characters[vch_id]
                if not vch.is_npc() \
                        and vch.level < merc.LEVEL_IMMORTAL \
                        and ch.level >= vch.level - 5 \
                        and (not ch.act.is_set(merc.ACT_WIMPY) or not vch.is_awake()) \
                        and ch.can_see(vch):
                    if random.randint(0, count) == 0:
                        victim = vch
                    count += 1

            if not victim:
                continue

            fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
Example #10
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
Example #11
0
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
Example #12
0
def spec_guard(ch):
    if not ch.is_awake() or ch.fighting is not None:
        return False

    max_evil = 300
    ech = None
    crime = ""
    victim = None
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]
        if not vch.is_npc() and vch.act.is_set(
                merc.PLR_KILLER) and ch.can_see(vch):
            victim = vch
            crime = "KILLER"
            break

        if not vch.is_npc() and vch.act.is_set(
                merc.PLR_THIEF) and ch.can_see(vch):
            crime = "THIEF"
            victim = vch
            break

        if vch.fighting and vch.fighting != ch and vch.alignment < max_evil:
            max_evil = vch.alignment
            ech = vch

    if victim:
        buf = "%s is a %s!  PROTECT THE INNOCENT!!  BANZAI!!" % (victim.name,
                                                                 crime)
        ch.comm.rem_bit(merc.COMM_NOSHOUT)
        ch.do_yell(buf)
        fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
        return True

    if ech:
        handler_game.act("$n screams 'PROTECT THE INNOCENT!!  BANZAI!!", ch,
                         None, None, merc.TO_ROOM)
        fight.multi_hit(ch, ech, merc.TYPE_UNDEFINED)
        return True
    return False
Example #13
0
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
Example #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()
Example #15
0
def spec_executioner(ch):
    if not ch.is_awake() or ch.fighting is not None:
        return False

    crime = ""
    victim = None
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]
        if not vch.is_npc() and vch.act.is_set(merc.PLR_KILLER) and ch.can_see(vch):
            victim = vch
            crime = "KILLER"

        if not vch.is_npc() and vch.act.is_set(merc.PLR_THIEF) and ch.can_see(vch):
            victim = vch
            crime = "THIEF"

    if victim is None:
        return False

    ch.comm.rem_bit(merc.COMM_NOSHOUT)
    ch.do_yell("%s is a %s!  PROTECT THE INNOCENT!  MORE BLOOOOD!!!" % (victim.name, crime))
    fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
    return True
Example #16
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
Example #17
0
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
Example #18
0
def spec_guard(ch):
    if not ch.is_awake() or ch.fighting is not None:
        return False

    max_evil = 300
    ech = None
    crime = ""
    victim = None
    for vch_id in ch.in_room.people[:]:
        vch = instance.characters[vch_id]
        if not vch.is_npc() and vch.act.is_set(merc.PLR_KILLER) and ch.can_see(vch):
            victim = vch
            crime = "KILLER"
            break

        if not vch.is_npc() and vch.act.is_set(merc.PLR_THIEF) and ch.can_see(vch):
            crime = "THIEF"
            victim = vch
            break

        if vch.fighting and vch.fighting != ch and vch.alignment < max_evil:
            max_evil = vch.alignment
            ech = vch

    if victim:
        buf = "%s is a %s!  PROTECT THE INNOCENT!!  BANZAI!!" % (victim.name, crime)
        ch.comm.rem_bit(merc.COMM_NOSHOUT)
        ch.do_yell(buf)
        fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
        return True

    if ech:
        handler_game.act("$n screams 'PROTECT THE INNOCENT!!  BANZAI!!", ch, None, None, merc.TO_ROOM)
        fight.multi_hit(ch, ech, merc.TYPE_UNDEFINED)
        return True
    return False
Example #19
0
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)
Example #20
0
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)
Example #21
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)
Example #22
0
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
Example #23
0
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
Example #24
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)
Example #25
0
    def check_social(self, command, argument):
        cmd = None
        for key, social in const.social_table.items():
            if command[0] == social.name[0] and game_utils.str_prefix(
                    command, social.name):
                cmd = social
                break

        if not cmd:
            return False

        if not self.is_npc() and self.sentances.is_set(merc.SENT_NO_EMOTE):
            self.send("You are anti-social!\n")
            return True

        if self.position == merc.POS_DEAD:
            self.send("Lie still; you are DEAD.\n")
            return True
        if self.position in [merc.POS_INCAP, merc.POS_MORTAL]:
            self.send("You are hurt far too bad for that.\n")
            return True
        if self.position == merc.POS_STUNNED:
            self.send("You are too stunned to do that.\n")
            return True
        if self.position == merc.POS_SLEEPING:
            # I just know this is the path to a 12" 'if' statement.  :(
            # But two players asked for it already!  -- Furey
            if not game_utils.str_cmp(cmd.name, "snore"):
                self.send("In your dreams, or what?\n")
                return True

        holder, arg = game_utils.read_word(argument)
        victim = self.get_char_room(arg)
        if not arg:
            handler_game.act(cmd.others_no_arg, self, None, victim,
                             merc.TO_ROOM)
            handler_game.act(cmd.char_no_arg, self, None, victim, merc.TO_CHAR)
        elif not victim:
            self.not_here(arg)
        elif victim == self:
            handler_game.act(cmd.others_auto, self, None, victim, merc.TO_ROOM)
            handler_game.act(cmd.char_auto, self, None, victim, merc.TO_CHAR)
        else:
            handler_game.act(cmd.others_found, self, None, victim,
                             merc.TO_NOTVICT)
            handler_game.act(cmd.char_found, self, None, victim, merc.TO_CHAR)
            handler_game.act(cmd.vict_found, self, None, victim, merc.TO_VICT)

            if not self.is_npc() and victim.is_npc(
            ) and not victim.is_affected(merc.AFF_CHARM) and victim.is_awake():
                chance = game_utils.number_bits(4)
                if chance == 0:
                    fight.multi_hit(victim, self, merc.TYPE_UNDEFINED)
                elif chance in [1, 2, 3, 4, 5, 6, 7, 8]:
                    handler_game.act(cmd.others_found, victim, None, self,
                                     merc.TO_NOTVICT)
                    handler_game.act(cmd.char_found, victim, None, self,
                                     merc.TO_CHAR)
                    handler_game.act(cmd.vict_found, victim, None, self,
                                     merc.TO_VICT)
                elif chance in [9, 10, 11, 12]:
                    handler_game.act("$n slaps $N.", victim, None, self,
                                     merc.TO_NOTVICT)
                    handler_game.act("You slap $N.", victim, None, self,
                                     merc.TO_CHAR)
                    handler_game.act("$n slaps you.", victim, None, self,
                                     merc.TO_VICT)
        return True
Example #26
0
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)
Example #27
0
def aggr_update():
    for wch in list(instance.players.values()):
        item = wch.chobj
        if item and not wch.is_npc():
            # noinspection PyUnresolvedReferences
            if item.in_room:
                # noinspection PyUnresolvedReferences
                itemroom = item.in_room
            elif item.in_item:
                itemroom = instance.rooms[merc.ROOM_VNUM_IN_OBJECT]
            elif item.in_living:
                # noinspection PyUnresolvedReferences
                if item.in_living != wch and item.in_living.in_room:
                    # noinspection PyUnresolvedReferences
                    itemroom = item.in_living.in_room
                else:
                    continue
            else:
                continue
            if itemroom and wch.in_room != itemroom:
                wch.in_room.get(wch)
                itemroom.put(wch)
                wch.cmd_look("auto")
        elif not wch.is_npc() and (wch.head.is_set(merc.LOST_HEAD)
                                   or wch.extra.is_set(merc.EXTRA_OSWITCH)
                                   or wch.obj_vnum != 0):
            if wch.obj_vnum != 0:
                wch.bind_char()
                continue

            if wch.head.is_set(merc.LOST_HEAD):
                wch.head.rem_bit(merc.LOST_HEAD)
                wch.send("You are able to regain a body.\n")
                wch.position = merc.POS_RESTING
                wch.hit = 1
            else:
                wch.send("You return to your body.\n")
                wch.extra.rem_bit(merc.EXTRA_OSWITCH)

            wch.affected_by.rem_bit(merc.AFF_POLYMORPH)
            wch.morph = ""
            wch.in_room.get(wch)
            room_id = instance.instances_by_room[merc.ROOM_VNUM_ALTAR][0]
            instance.rooms[room_id].put(wch)

            item = wch.chobj
            if item:
                item.chobj = None
            wch.chobj = None
            wch.cmd_look("auto")
        continue

    for wch in list(instance.characters.values()):
        item = wch.chobj
        if wch.is_npc() or (wch.desc and wch.desc.is_connected(nanny.con_playing)) or wch.position <= merc.POS_STUNNED or wch.is_immortal() or \
                item or not wch.in_room:
            continue

        for ch_id in wch.in_room.people[:]:
            ch = instance.characters[ch_id]
            if not ch.is_npc() or not ch.act.is_set(merc.ACT_AGGRESSIVE) or fight.no_attack(ch, wch) or ch.fighting or \
                    ch.is_affected(merc.AFF_CHARM) or not ch.is_awake() or (ch.act.is_set(merc.ACT_WIMPY) and wch.is_awake()) or not ch.can_see(wch):
                continue

            # Ok we have a 'wch' player character and a 'ch' npc aggressor.
            # Now make the aggressor fight a RANDOM pc victim in the room,
            #   giving each 'vch' an equal chance of selection.
            count = 0
            victim = None
            for vch_id in wch.in_room.people[:]:
                vch = instance.characters[vch_id]
                item = vch.chobj
                if not vch.is_npc() and not fight.no_attack(ch, vch) and not item and vch.level < merc.LEVEL_IMMORTAL and \
                        vch.position > merc.POS_STUNNED and (not ch.act.is_set(merc.ACT_WIMPY) or not vch.is_awake()) and ch.can_see(vch):
                    if game_utils.number_range(0, count) == 0:
                        victim = vch
                    count += 1

            if not victim:
                continue

            fight.multi_hit(ch, victim, merc.TYPE_UNDEFINED)
Example #28
0
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
Example #29
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
Example #30
0
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