Ejemplo n.º 1
0
def npc_update():
    # Examine all mobs. */
    for npc in instance.characters.values():
        if not npc.is_npc() or npc.in_room is None or npc.is_affected(merc.AFF_CHARM):
            continue

        if instance.area_templates[npc.in_room.area] and not npc.act.is_set(merc.ACT_UPDATE_ALWAYS):
            continue

        # Examine call for special procedure */
        if npc.spec_fun:
            if npc.spec_fun(npc):
                continue

        if npc.pShop:  # give him some gold */
            if (npc.gold * 100 + npc.silver) < npc.wealth:
                npc.gold += npc.wealth * random.randint(1, 20) // 5000000
                npc.silver += npc.wealth * random.randint(1, 20) // 50000

        # That's all for sleeping / busy monster, and empty zones */
        if npc.position != merc.POS_STANDING:
            continue

        # Scavenge */
        if npc.act.is_set(merc.ACT_SCAVENGER) and npc.in_room.items is not None and random.randint(0, 6) == 0:
            top = 1
            item_best = None
            for item_id in npc.in_room.items:
                item = instance.items[item_id]
                if item.take and npc.can_loot(item) and item.cost > top and item.cost > 0:
                    item_best = item
                    top = item.cost

            if item_best:
                item_best.from_environment()
                item_best.to_environment(npc.instance_id)
                handler_game.act("$n gets $p.", npc, item_best, None, merc.TO_ROOM)

        # Wander */
        door = random.randint(0, 5)
        pexit = npc.in_room.exit[door]

        if not npc.act.is_set(merc.ACT_SENTINEL) \
                and random.randint(0, 3) == 0 \
                and pexit \
                and pexit.to_room \
                and not pexit.exit_info.is_set(merc.EX_CLOSED) \
                and not state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB) \
                and (not npc.act.is_set(merc.ACT_STAY_AREA)
                     or instance.rooms[pexit.to_room].area == npc.in_room.area) \
                and (not npc.act.is_set(merc.ACT_OUTDOORS)
                     or not state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_INDOORS)) \
                and (not npc.act.is_set(merc.ACT_INDOORS)
                     or state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_INDOORS)):
            handler_ch.move_char(npc, door, False)
Ejemplo n.º 2
0
def spec_mayor(ch):
    open_path = "W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S."

    close_path = "W3a3003b33000c111d0d111CE333333CE22c222112212111a1S."

    global pos, move, path

    if not move:
        if handler_game.time_info.hour == 6:
            path = open_path
            move = True
            pos = 0

        if handler_game.time_info.hour == 20:
            path = close_path
            move = True
            pos = 0

    if ch.fighting is not None:
        return spec_cast_mage(ch)
    if not move or ch.position < merc.POS_SLEEPING:
        return False

    if path[pos] == '0' or path[pos] == '1' or path[pos] == '2' or path[pos] == '3':
        handler_ch.move_char(ch, int(path[pos]), False)
    elif path[pos] == 'W':
        ch.position = merc.POS_STANDING
        handler_game.act("$n awakens and groans loudly.", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'S':
        ch.position = merc.POS_SLEEPING
        handler_game.act("$n lies down and falls asleep.", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'a':
        handler_game.act("$n says 'Hello Honey!'", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'b':
        handler_game.act("$n says 'What a view!  I must do something about that dump!'", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'c':
        handler_game.act("$n says 'Vandals!  Youngsters have no respect for anything!'", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'd':
        handler_game.act("$n says 'Good day, citizens!'", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'e':
        handler_game.act("$n says 'I hereby declare the city of Midgaard open!'", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'E':
        handler_game.act("$n says 'I hereby declare the city of Midgaard closed!'", ch, None, None, merc.TO_ROOM)
    elif path[pos] == 'O':
        # do_function(ch, &do_unlock, "gate" ) */
        ch.do_open("gate")
    elif 'C':
        ch.do_close("gate")
        # do_function(ch, &do_lock, "gate" ) */
    elif path[pos] == '.':
        move = False
    pos += 1
    return False
Ejemplo n.º 3
0
def cmd_flee(ch, argument):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

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

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

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

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

        handler_ch.move_char(ch, door)

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

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

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

        fight.stop_fighting(ch, True)
        return

    ch.send("You were unable to escape!\n")
Ejemplo n.º 4
0
def cmd_south(ch, argument):
    if ch.is_affected(merc.AFF_WEBBED):
        ch.send("You are unable to move with all this sticky webbing on.\n")
        return

    in_room = ch.in_room
    handler_ch.move_char(ch, merc.DIR_SOUTH)

    if not ch.is_npc() and ch.in_room != in_room:
        old_room = ch.in_room
        ch.in_room.get(ch)
        in_room.put(ch)
        handler_ch.add_tracks(ch, merc.DIR_SOUTH)
        ch.in_room.get(ch)
        old_room.put(ch)
Ejemplo n.º 5
0
def do_flee(ch, argument):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

    was_in = ch.in_room
    for attempt in range(6):
        door = handler_room.number_door()
        pexit = was_in.exit[door]
        if not pexit \
                or not pexit.to_room \
                or pexit.exit_info.is_set(merc.EX_CLOSED) \
                or random.randint(0, ch.daze) != 0 \
                or (ch.is_npc()
                    and state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)):
            continue

        handler_ch.move_char(ch, door, False)
        now_in = ch.in_room
        if now_in == was_in:
            continue
        ch.in_environment = was_in.instance_id
        handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM)
        ch.in_environment = now_in.instance_id

        if not ch.is_npc():
            ch.send("You flee from combat!\n")
            if ch.guild.name == 'thief' and (random.randint(1, 99) < 3 *
                                             (ch.level // 2)):
                ch.send("You snuck away safely.\n")
            else:
                ch.send("You lost 10 exp.\n")
                update.gain_exp(ch, -10)

        fight.stop_fighting(ch, True)
        return
    ch.send("PANIC! You couldn't escape!\n")
    return
Ejemplo n.º 6
0
def do_flee( ch, argument ):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

    was_in = ch.in_room
    for attempt in range(6):
        door = handler_room.number_door()
        pexit = was_in.exit[door]
        if not pexit \
                or not pexit.to_room \
                or pexit.exit_info.is_set(merc.EX_CLOSED) \
                or random.randint(0, ch.daze) != 0 \
                or (ch.is_npc()
                    and state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)):
            continue

        handler_ch.move_char(ch, door, False)
        now_in = ch.in_room
        if now_in == was_in:
            continue
        ch.in_environment = was_in.instance_id
        handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM)
        ch.in_environment = now_in.instance_id

        if not ch.is_npc():
            ch.send("You flee from combat!\n")
            if ch.guild.name == 'thief' and (random.randint(1, 99) < 3 * (ch.level // 2)):
                ch.send("You snuck away safely.\n")
            else:
                ch.send("You lost 10 exp.\n")
                update.gain_exp(ch, -10)

        fight.stop_fighting(ch, True)
        return
    ch.send("PANIC! You couldn't escape!\n")
    return
Ejemplo n.º 7
0
def do_south(ch, argument):
    handler_ch.move_char(ch, merc.DIR_SOUTH, False)
    return
Ejemplo n.º 8
0
def do_up(ch, argument):
    handler_ch.move_char(ch, merc.DIR_UP, False)
    return
Ejemplo n.º 9
0
def npc_update():
    # Examine all mobs. */
    for npc in instance.characters.values():
        if not npc.is_npc() or npc.in_room is None or npc.is_affected(
                merc.AFF_CHARM):
            continue

        if instance.area_templates[npc.in_room.area] and not npc.act.is_set(
                merc.ACT_UPDATE_ALWAYS):
            continue

        # Examine call for special procedure */
        if npc.spec_fun:
            if npc.spec_fun(npc):
                continue

        if npc.pShop:  # give him some gold */
            if (npc.gold * 100 + npc.silver) < npc.wealth:
                npc.gold += npc.wealth * random.randint(1, 20) // 5000000
                npc.silver += npc.wealth * random.randint(1, 20) // 50000

        # That's all for sleeping / busy monster, and empty zones */
        if npc.position != merc.POS_STANDING:
            continue

        # Scavenge */
        if npc.act.is_set(
                merc.ACT_SCAVENGER
        ) and npc.in_room.items is not None and random.randint(0, 6) == 0:
            top = 1
            item_best = None
            for item_id in npc.in_room.items:
                item = instance.items[item_id]
                if item.take and npc.can_loot(
                        item) and item.cost > top and item.cost > 0:
                    item_best = item
                    top = item.cost

            if item_best:
                item_best.from_environment()
                item_best.to_environment(npc.instance_id)
                handler_game.act("$n gets $p.", npc, item_best, None,
                                 merc.TO_ROOM)

        # Wander */
        door = random.randint(0, 5)
        pexit = npc.in_room.exit[door]

        if not npc.act.is_set(merc.ACT_SENTINEL) \
                and random.randint(0, 3) == 0 \
                and pexit \
                and pexit.to_room \
                and not pexit.exit_info.is_set(merc.EX_CLOSED) \
                and not state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB) \
                and (not npc.act.is_set(merc.ACT_STAY_AREA)
                     or instance.rooms[pexit.to_room].area == npc.in_room.area) \
                and (not npc.act.is_set(merc.ACT_OUTDOORS)
                     or not state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_INDOORS)) \
                and (not npc.act.is_set(merc.ACT_INDOORS)
                     or state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_INDOORS)):
            handler_ch.move_char(npc, door, False)
Ejemplo n.º 10
0
def do_west(ch, argument):
    handler_ch.move_char(ch, merc.DIR_WEST, False)
    return
Ejemplo n.º 11
0
def do_north(ch, argument):
    handler_ch.move_char(ch, merc.DIR_NORTH, False)
    return
Ejemplo n.º 12
0
def do_up(ch, argument):
    handler_ch.move_char(ch, merc.DIR_UP, False)
    return
Ejemplo n.º 13
0
def do_east(ch, argument):
    handler_ch.move_char(ch, merc.DIR_EAST, False)
    return
Ejemplo n.º 14
0
def do_north(ch, argument):
    handler_ch.move_char(ch, merc.DIR_NORTH, False)
    return
Ejemplo n.º 15
0
def spec_mayor(ch):
    open_path = "W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S."

    close_path = "W3a3003b33000c111d0d111CE333333CE22c222112212111a1S."

    global pos, move, path

    if not move:
        if handler_game.time_info.hour == 6:
            path = open_path
            move = True
            pos = 0

        if handler_game.time_info.hour == 20:
            path = close_path
            move = True
            pos = 0

    if ch.fighting is not None:
        return spec_cast_mage(ch)
    if not move or ch.position < merc.POS_SLEEPING:
        return False

    if path[pos] == '0' or path[pos] == '1' or path[pos] == '2' or path[
            pos] == '3':
        handler_ch.move_char(ch, int(path[pos]), False)
    elif path[pos] == 'W':
        ch.position = merc.POS_STANDING
        handler_game.act("$n awakens and groans loudly.", ch, None, None,
                         merc.TO_ROOM)
    elif path[pos] == 'S':
        ch.position = merc.POS_SLEEPING
        handler_game.act("$n lies down and falls asleep.", ch, None, None,
                         merc.TO_ROOM)
    elif path[pos] == 'a':
        handler_game.act("$n says 'Hello Honey!'", ch, None, None,
                         merc.TO_ROOM)
    elif path[pos] == 'b':
        handler_game.act(
            "$n says 'What a view!  I must do something about that dump!'", ch,
            None, None, merc.TO_ROOM)
    elif path[pos] == 'c':
        handler_game.act(
            "$n says 'Vandals!  Youngsters have no respect for anything!'", ch,
            None, None, merc.TO_ROOM)
    elif path[pos] == 'd':
        handler_game.act("$n says 'Good day, citizens!'", ch, None, None,
                         merc.TO_ROOM)
    elif path[pos] == 'e':
        handler_game.act(
            "$n says 'I hereby declare the city of Midgaard open!'", ch, None,
            None, merc.TO_ROOM)
    elif path[pos] == 'E':
        handler_game.act(
            "$n says 'I hereby declare the city of Midgaard closed!'", ch,
            None, None, merc.TO_ROOM)
    elif path[pos] == 'O':
        # do_function(ch, &do_unlock, "gate" ) */
        ch.do_open("gate")
    elif 'C':
        ch.do_close("gate")
        # do_function(ch, &do_lock, "gate" ) */
    elif path[pos] == '.':
        move = False
    pos += 1
    return False
Ejemplo n.º 16
0
def do_down(ch, argument):
    handler_ch.move_char(ch, merc.DIR_DOWN, False)
    return
Ejemplo n.º 17
0
def do_south(ch, argument):
    handler_ch.move_char(ch, merc.DIR_SOUTH, False)
    return
Ejemplo n.º 18
0
def do_east(ch, argument):
    handler_ch.move_char(ch, merc.DIR_EAST, False)
    return