示例#1
0
def crack_head(ch, item, argument):
    argument, arg1 = game_utils.read_word(argument)
    argument, arg2 = game_utils.read_word(argument)

    if not game_utils.str_cmp(arg2, "mob") and item.chobj and not item.chobj.is_npc() and item.chobj.is_affected(merc.AFF_POLYMORPH):
        victim = item.chobj
        object_creator.make_part(victim, "cracked_head")
        object_creator.make_part(victim, "brain")
        victim.morph = "the quivering brain of {}".format(victim.name)
    elif game_utils.str_cmp(arg2, "mob"):
        mob_index = instance.npc_templates[item.value[1]]
        if not mob_index:
            return

        victim = object_creator.create_mobile(mob_index)
        ch.in_room.put(victim)
        object_creator.make_part(victim, "cracked_head")
        object_creator.make_part(victim, "brain")
        victim.extract(True)
    else:
        mob_index = instance.npc_templates[30002]
        if not mob_index:
            return

        victim = object_creator.create_mobile(mob_index)
        victim.short_descr = arg2[0].upper() + arg2[1:]
        ch.in_room.put(victim)
        object_creator.make_part(victim, "cracked_head")
        object_creator.make_part(victim, "brain")
        victim.extract(True)
示例#2
0
def item_update():
    for item in list(instance.items.values()):
        if item:
            if item.timer <= 0:
                continue

            item.timer -= 1
            if item.timer > 0:
                continue

            if item.item_type == merc.ITEM_FOUNTAIN:
                message = "$p dries up."
            elif item.item_type in [merc.ITEM_CORPSE_NPC, merc.ITEM_CORPSE_PC]:
                message = "$p decays into dust."
            elif item.item_type == merc.ITEM_FOOD:
                message = "$p decomposes."
            elif item.item_type == merc.ITEM_TRASH:
                message = "$p crumbles into dust."
            elif item.item_type == merc.ITEM_EGG:
                message = "$p cracks open."
            elif item.item_type == merc.ITEM_WEAPON:
                message = "The poison on $p melts through it."
            else:
                message = "$p vanishes."

            if item.in_living:
                handler_game.act(message, instance.characters[item.in_living],
                                 item, None, merc.TO_CHAR)
            elif item.in_room and item.in_room.people:
                ch = instance.characters[item.in_room.people[0]]
                handler_game.act(message, ch, item, None, merc.TO_ROOM)

            # If the item is an egg, we need to create a mob and shell! KaVir
            if item.item_type == merc.ITEM_EGG:
                mob_index = instance.npc_templates[item.value[0]]
                if mob_index:
                    if item.in_living and item.in_living.in_room:
                        creature = object_creator.create_mobile(mob_index)
                        item.in_living.in_room.put(creature)
                    elif item.in_room:
                        creature = object_creator.create_mobile(mob_index)
                        item.in_room.put(creature)
                    else:
                        creature = object_creator.create_mobile(mob_index)
                        room_id = instance.instances_by_room[
                            merc.ROOM_VNUM_HELL][0]
                        instance.rooms[room_id].put(creature)
                    egg = object_creator.clone_item(
                        instance.item_templates[merc.OBJ_VNUM_EMPTY_EGG], 0)
                    egg.timer = 2
                    creature.in_room.put(egg)
                    handler_game.act("$n clambers out of $p.", creature, item,
                                     None, merc.TO_ROOM)
                elif item.in_room:
                    egg = object_creator.clone_item(
                        instance.item_templates[merc.OBJ_VNUM_EMPTY_EGG], 0)
                    egg.timer = 2
                    item.in_room.put(egg)
            item.extract()
示例#3
0
def spl_mount(sn, level, ch, victim, target):
    if ch.is_npc():
        return

    if ch.followers > 4:
        ch.send("Nothing happens.\n")
        return

    ch.followers += 1
    level = max(1, level)

    if ch.is_demon():
        victim = object_creator.create_mobile(
            instance.npc_templates[merc.MOB_VNUM_HOUND])
        victim.level = level * 2
        victim.armor = 0 - (10 * level)
        victim.hitroll = level * 2
        victim.damroll = level * 2
        victim.hit = 250 * level
        victim.max_hit = 250 * level
        victim.lord = ch.name
        ch.is_room.put(victim)
        handler_game.act("$N fades into existance.", ch, None, victim,
                         merc.TO_CHAR)
        handler_game.act("$N fades into existance.", ch, None, victim,
                         merc.TO_ROOM)
        return

    victim = object_creator.create_mobile(
        instance.npc_templates[merc.MOB_VNUM_MOUNT])
    victim.level = level
    victim.armor = 0 - (2 * level)
    victim.hitroll = level
    victim.damroll = level
    victim.hit = 100 * level
    victim.max_hit = 100 * level
    victim.lord = ch.name
    victim.affected_by.set_bit(merc.AFF_FLYING)

    if ch.is_good():
        victim.name = "mount white horse pegasus"
        victim.short_descr = "{}'s white pegasus".format(ch.name)
        victim.long_descr = "A beautiful white pegasus stands here.\n"
    elif ch.is_evil():
        victim.name = "mount griffin"
        victim.short_descr = "{}'s griffin".format(ch.name)
        victim.long_descr = "A vicious looking griffin stands here.\n"
    else:
        victim.name = "mount black horse nightmare"
        victim.short_descr = "{}'s black nightmare".format(ch.name)
        victim.long_descr = "A large black demonic horse stands here.\n"

    ch.in_room.put(victim)
    handler_game.act("$N fades into existance.", ch, None, victim,
                     merc.TO_CHAR)
    handler_game.act("$N fades into existance.", ch, None, victim,
                     merc.TO_ROOM)
示例#4
0
def spl_guardian(sn, level, ch, victim, target):
    if ch.followers > 4:
        ch.send("Nothing happens.\n")
        return

    ch.followers += 1
    victim = object_creator.create_mobile(
        instance.npc_templates[merc.MOB_VNUM_GUARDIAN])
    victim.level = level
    victim.hit = 100 * level
    victim.max_hit = 100 * level
    victim.hitroll = level
    victim.damroll = level
    victim.armor = 100 - (level * 7)

    ch.cmd_say("Come forth, creature of darkness, and do my bidding!")
    ch.send("A demon bursts from the ground and bows before you.\n")
    handler_game.act("$N bursts from the ground and bows before $n.", ch, None,
                     victim, merc.TO_ROOM)
    ch.in_room.put(victim)
    handler_ch.add_follower(victim, ch)

    aff = handler_game.AffectData(type=sn,
                                  duration=666,
                                  location=merc.APPLY_NONE,
                                  bitvector=merc.AFF_CHARM)
    victim.affect_join(aff)
示例#5
0
def cmd_eyespy(ch, argument):
    if ch.head.is_set(merc.LOST_EYE_L) and ch.head.is_set(merc.LOST_EYE_R):
        ch.send("But you don't have any more eyes to pluck out!\n")
        return

    if not ch.head.is_set(merc.LOST_EYE_L) and game_utils.number_range(1, 2) == 1:
        handler_game.act("You pluck out your left eyeball and throw it to the ground.", ch, None, None, merc.TO_CHAR)
        handler_game.act("$n plucks out $s left eyeball and throws it to the ground.", ch, None, None, merc.TO_ROOM)
    elif not ch.head.is_set(merc.LOST_EYE_R):
        handler_game.act("You pluck out your right eyeball and throw it to the ground.", ch, None, None, merc.TO_CHAR)
        handler_game.act("$n plucks out $s right eyeball and throws it to the ground.", ch, None, None, merc.TO_ROOM)
    else:
        handler_game.act("You pluck out your left eyeball and throw it to the ground.", ch, None, None, merc.TO_CHAR)
        handler_game.act("$n plucks out $s left eyeball and throws it to the ground.", ch, None, None, merc.TO_ROOM)

    familiar = ch.familiar
    if familiar:
        object_creator.make_part(ch, "eyeball")
        return

    if merc.MOB_VNUM_EYE not in instance.npc_templates:
        ch.send("Error - please inform an Immortal.\n")
        return

    victim = object_creator.create_mobile(instance.npc_templates[merc.MOB_VNUM_EYE])
    ch.in_room.put(victim)
    ch.familiar = victim
    victim.wizard = ch
示例#6
0
def m_reset(pReset, last, level, npc):
    if pReset.arg1 not in instance.npc_templates.keys():
        logger.error("Reset_area: 'M': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        npcTemplate = instance.npc_templates[pReset.arg1]

    if pReset.arg3 not in instance.room_templates.keys():
        logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg3][0]
        roomInstance = instance.global_instances[roomInstance_id]

    if npcTemplate.count >= pReset.arg2:
        last = False
        return last, level, npc
    count = 0
    for npc_id in roomInstance.people[:]:
        npc = instance.global_instances[npc_id]
        if npc.is_npc():
            if npc.vnum == npcTemplate.vnum:
                count += 1
                if count >= pReset.arg4:
                    last = False
                    break

    if count >= pReset.arg4:
        return last, level, npc

    npc = object_creator.create_mobile(npcTemplate)

    #
    # * Check for pet shop.
    # */

    if roomInstance.vnum - 1 in instance.room_templates.keys():
        prevRoomInstance_id = instance.instances_by_room[roomInstance.vnum -
                                                         1][0]
        prevRoomInstance = instance.global_instances[prevRoomInstance_id]
        if state_checks.IS_SET(prevRoomInstance.room_flags,
                               merc.ROOM_PET_SHOP):
            npc.act.set_bit(merc.ACT_PET)

    # set area */
    npc.area = roomInstance.area

    roomInstance.put(npc)
    level = max(0, min(npc.level - 2, merc.LEVEL_HERO - 1))
    last = True
    return last, level, npc
示例#7
0
文件: db.py 项目: carriercomm/PyRom
def m_reset(pReset, last, level, npc):
    if pReset.arg1 not in instance.npc_templates.keys():
            logger.error("Reset_area: 'M': bad vnum %d.", pReset.arg1)
            return last, level, npc
    else:
        npcTemplate = instance.npc_templates[pReset.arg1]

    if pReset.arg3 not in instance.room_templates.keys():
        logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg3][0]
        roomInstance = instance.global_instances[roomInstance_id]

    if npcTemplate.count >= pReset.arg2:
        last = False
        return last, level, npc
    count = 0
    for npc_id in roomInstance.people[:]:
        npc = instance.global_instances[npc_id]
        if npc.is_npc():
            if npc.vnum == npcTemplate.vnum:
                count += 1
                if count >= pReset.arg4:
                    last = False
                    break

    if count >= pReset.arg4:
        return last, level, npc

    npc = object_creator.create_mobile(npcTemplate)

    #
    # * Check for pet shop.
    # */

    if roomInstance.vnum - 1 in instance.room_templates.keys():
        prevRoomInstance_id = instance.instances_by_room[roomInstance.vnum - 1][0]
        prevRoomInstance = instance.global_instances[prevRoomInstance_id]
        if state_checks.IS_SET(prevRoomInstance.room_flags, merc.ROOM_PET_SHOP):
            npc.act.set_bit(merc.ACT_PET)

    # set area */
    npc.area = roomInstance.area

    roomInstance.put(npc)
    level = max(0, min(npc.level - 2, merc.LEVEL_HERO - 1))
    last = True
    return last, level, npc
示例#8
0
def cmd_mload(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg or not arg.isdigit():
        ch.send("Syntax: mload <vnum>\n")
        return

    vnum = int(arg)
    if vnum not in instance.npc_templates:
        ch.send("No mob has that vnum.\n")
        return

    victim = object_creator.create_mobile(instance.npc_templates[vnum])
    ch.in_room.put(victim)
    handler_game.act("$n has created $N!", ch, None, victim, merc.TO_ROOM)
    handler_game.act("You have created $N!", ch, None, victim, merc.TO_CHAR)
示例#9
0
def do_mload(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg or not arg.isdigit():
        ch.send("Syntax: load mob <vnum>.\n")
        return
    vnum = int(arg)
    if vnum not in instance.npc_templates:
        ch.send("No mob has that vnum.\n")
        return
    template = instance.npc_templates[vnum]
    victim = object_creator.create_mobile(template)
    ch.in_room.put(victim)
    handler_game.act("$n has created $N!", ch, None, victim, merc.TO_ROOM)
    handler_game.wiznet("$N loads %s." % victim.short_descr, ch, None, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust)
    ch.send("Ok.\n")
    return
示例#10
0
def do_mload(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg or not arg.isdigit():
        ch.send("Syntax: load mob <vnum>.\n")
        return
    vnum = int(arg)
    if vnum not in instance.npc_templates:
        ch.send("No mob has that vnum.\n")
        return
    template = instance.npc_templates[vnum]
    victim = object_creator.create_mobile(template)
    ch.in_room.put(victim)
    handler_game.act("$n has created $N!", ch, None, victim, merc.TO_ROOM)
    handler_game.wiznet("$N loads %s." % victim.short_descr, ch, None,
                        merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust)
    ch.send("Ok.\n")
    return
示例#11
0
def m_reset(preset, last, level, npc):
    if preset.arg1 not in instance.npc_templates.keys():
        comm.notify("m_reset: 'M': bad vnum {}".format(preset.arg1),
                    merc.CONSOLE_WARNING)
        return last, level, npc
    else:
        npc_template = instance.npc_templates[preset.arg1]

    if preset.arg3 not in instance.room_templates.keys():
        comm.notify("reset_area: 'R': bad vnum {}".format(preset.arg3),
                    merc.CONSOLE_WARNING)
        return last, level, npc
    else:
        room_instance_id = instance.instances_by_room[preset.arg3][0]
        room_instance = instance.global_instances[room_instance_id]

    level = state_checks.urange(0, npc_template.level - 2, merc.LEVEL_HERO)
    if npc_template.count >= preset.arg2:
        last = False
        return last, level, npc

    npc = object_creator.create_mobile(npc_template)

    # Check for pet shop.
    if room_instance.vnum - 1 in instance.room_templates.keys():
        prev_room_instance_id = instance.instances_by_room[room_instance.vnum -
                                                           1][0]
        prev_room_instance = instance.global_instances[prev_room_instance_id]
        if prev_room_instance.room_flags.is_set(merc.ROOM_PET_SHOP):
            npc.act.set_bit(merc.ACT_PET)

    if room_instance.is_dark():
        npc.affected_by.set_bit(merc.AFF_INFRARED)

    # set area
    npc.area = room_instance.area

    room_instance.put(npc)
    level = state_checks.urange(0, npc.level - 2, merc.LEVEL_HERO)
    last = True
    return last, level, npc
示例#12
0
def cmd_press(ch, argument):
    argument, arg1 = game_utils.read_word(argument)
    argument, arg2 = game_utils.read_word(argument)

    if not arg1:
        ch.send("Which item do you wish to press?\n")
        return

    item = ch.get_item_wear(arg1)
    if not item:
        item = ch.get_item_here(arg1)
        if not item:
            ch.send("You can't find that item.\n")
            return

        # You should only be able to use nontake items on floor
        if item.flags.take:
            ch.send("But you are not wearing it!\n")
            return

    if not item.spectype.is_set(merc.SITEM_PRESS):
        ch.send("There is nothing on this item to press.\n")
        return

    if item.spectype.is_set(merc.SITEM_TARGET) and not arg2:
        ch.send("Who do you wish to use it on?\n")
        return

    if item.spectype.is_set(merc.SITEM_TARGET):
        victim = ch.get_char_room(arg2)
        if not victim:
            ch.not_here(arg2)
            return
    else:
        victim = ch

    if item.chpoweruse:
        handler_game.kavitem(item.chpoweruse, ch, item, None, merc.TO_CHAR)

    if item.victpoweruse:
        handler_game.kavitem(item.victpoweruse, ch, item, None, merc.TO_ROOM)

    if item.spectype.is_set(merc.SITEM_SPELL):
        castlevel = state_checks.urange(1, item.level, 60)
        handler_magic.obj_cast_spell(item.specpower, castlevel, ch, victim,
                                     None)
        ch.wait_state(merc.PULSE_VIOLENCE // 2)

        if item.spectype.is_set(merc.SITEM_DELAY1):
            ch.wait_state(merc.PULSE_VIOLENCE // 2)

        if item.spectype.is_set(merc.SITEM_DELAY2):
            ch.wait_state(merc.PULSE_VIOLENCE)
        return

    if item.spectype.is_set(merc.SITEM_TRANSPORTER):
        if item.chpoweron:
            handler_game.kavitem(item.chpoweron, ch, item, None, merc.TO_CHAR)

        if item.victpoweron:
            handler_game.kavitem(item.victpoweron, ch, item, None,
                                 merc.TO_ROOM)

        proomindex = instance.rooms[item.specpower]
        item.specpower = ch.in_room.vnum
        if not proomindex:
            return

        ch.in_room.get(ch)
        proomindex.put(ch)
        ch.cmd_look("auto")

        if item.chpoweroff:
            handler_game.kavitem(item.chpoweroff, ch, item, None, merc.TO_CHAR)

        if item.victpoweroff:
            handler_game.kavitem(item.victpoweroff, ch, item, None,
                                 merc.TO_ROOM)

        if not item.flags.artifact and ch.in_room.room_flags.is_set(
                merc.ROOM_NO_TELEPORT) and item.flags.take:
            ch.send("A powerful force hurls you from the room.\n")
            handler_game.act("$n is hurled from the room by a powerful force.",
                             ch, None, None, merc.TO_ROOM)
            ch.position = merc.POS_STUNNED
            ch.in_room.get(ch)
            room_id = instance.instances_by_room[merc.ROOM_VNUM_TEMPLE][0]
            instance.rooms[room_id].put(ch)
            handler_game.act(
                "$n appears in the room, and falls to the ground stunned.", ch,
                None, None, merc.TO_ROOM)

        mount = ch.mount
        if mount:
            mount.in_room.get(mount)
            ch.in_room.put(mount)
            mount.cmd_look("auto")
    elif item.spectype.is_set(merc.SITEM_TELEPORTER):
        if item.chpoweron:
            handler_game.kavitem(item.chpoweron, ch, item, None, merc.TO_CHAR)

        if item.victpoweron:
            handler_game.kavitem(item.victpoweron, ch, item, None,
                                 merc.TO_ROOM)

        proomindex = instance.rooms[item.specpower]
        if not proomindex:
            return

        ch.in_room.get(ch)
        proomindex.put(ch)
        ch.cmd_look("auto")

        if item.chpoweroff:
            handler_game.kavitem(item.chpoweroff, ch, item, None, merc.TO_CHAR)

        if item.victpoweroff:
            handler_game.kavitem(item.victpoweroff, ch, item, None,
                                 merc.TO_ROOM)

        if not item.flags.artifact and ch.in_room.room_flags.is_set(
                merc.ROOM_NO_TELEPORT) and item.flags.take:
            ch.send("A powerful force hurls you from the room.\n")
            handler_game.act("$n is hurled from the room by a powerful force.",
                             ch, None, None, merc.TO_ROOM)
            ch.position = merc.POS_STUNNED
            ch.in_room.get(ch)
            room_id = instance.instances_by_room[merc.ROOM_VNUM_TEMPLE][0]
            instance.rooms[room_id].put(ch)
            handler_game.act(
                "$n appears in the room, and falls to the ground stunned.", ch,
                None, None, merc.TO_ROOM)

        mount = ch.mount
        if mount:
            mount.in_room.get(mount)
            ch.in_room.put(mount)
            mount.cmd_look("auto")
    elif item.spectype.is_set(merc.SITEM_OBJECT):
        obj_index = instance.item_templates[item.specpower]
        if not obj_index:
            return

        item = object_creator.create_item(obj_index, ch.level)
        if item.flags.take:
            ch.put(item)
        else:
            ch.in_room.put(item)
    elif item.spectype.is_set(merc.SITEM_MOBILE):
        mob_index = instance.npc_templates[item.specpower]
        if not mob_index:
            return

        npc = object_creator.create_mobile(mob_index)
        ch.in_room.put(npc)
    elif item.spectype.is_set(merc.SITEM_ACTION):
        ch.interpret(item.victpoweron)

        if item.victpoweroff:
            for vch_id in ch.in_room.people[:]:
                vch = instance.characters[vch_id]

                if ch == vch:
                    continue

                vch.interpret(item.victpoweroff)
                continue
示例#13
0
def spl_gate(sn, level, ch, victim, target):
    mob = object_creator.create_mobile(instance.npc_templates[merc.MOB_VNUM_VAMPIRE])
    ch.in_room.put(mob)
示例#14
0
def cmd_buy(ch, argument):
    argument, arg = game_utils.read_word(argument)

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

    if ch.in_room.room_flags.is_set(merc.ROOM_PET_SHOP):
        if ch.is_npc():
            return

        proomindexnext = None
        if ch.in_room.vnum + 1 in instance.room_templates:
            proomindexnext = handler_room.get_room_by_vnum(ch.in_room.vnum + 1)
        if not proomindexnext:
            comm.notify(
                "cmd_buy: bad pet shop at vnum {}".format(ch.in_room.vnum),
                merc.CONSOLE_ERROR)
            ch.send("Sorry, you can't buy that here.\n")
            return

        in_room = ch.in_room
        ch.in_room = proomindexnext
        pet = ch.get_char_room(arg)
        ch.in_room = in_room

        if not pet or not pet.act.is_set(merc.ACT_PET):
            ch.send("Sorry, you can't buy that here.\n")
            return

        if ch.gold < 10 * pet.level * pet.level:
            ch.send("You can't afford it.\n")
            return

        if ch.level < pet.level:
            ch.send("You're not ready for this pet.\n")
            return

        ch.gold -= 10 * pet.level * pet.level
        pet = object_creator.create_mobile(instance.npc_templates[pet.vnum])
        pet.act.set_bit(merc.ACT_PET)
        pet.affected_by.set_bit(merc.AFF_CHARM)

        argument, arg = game_utils.read_word(argument)
        if arg:
            pet.name = "{} {}".format(pet.name, arg)

        pet.description = "{}A neck tag says 'I belong to {}'.\n".format(
            pet.description, ch.name)
        ch.in_room.put(pet)
        pet.add_follower(ch)
        ch.send("Enjoy your pet.\n")
        handler_game.act("$n bought $N as a pet.", ch, None, pet, merc.TO_ROOM)
    else:
        keeper = shop_utils.find_keeper(ch)
        if not keeper:
            return

        item = keeper.get_item_carry(arg)
        cost = shop_utils.get_cost(keeper, item, True)
        if cost <= 0 or not ch.can_see_item(item):
            handler_game.act("$n tells you 'I don't sell that -- try 'list''.",
                             keeper, None, ch, merc.TO_VICT)
            ch.reply = keeper
            return

        if ch.gold < cost:
            handler_game.act("$n tells you 'You can't afford to buy $p'.",
                             keeper, item, ch, merc.TO_VICT)
            ch.reply = keeper
            return

        if item.level > ch.level and ch.level < 3:
            handler_game.act("$n tells you 'You can't use $p yet'.", keeper,
                             item, ch, merc.TO_VICT)
            ch.reply = keeper
            return

        if ch.carry_number + 1 > ch.can_carry_n():
            ch.send("You can't carry that many items.\n")
            return

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

        handler_game.act("$n buys $p.", ch, item, None, merc.TO_ROOM)
        handler_game.act("You buy $p.", ch, item, None, merc.TO_CHAR)
        ch.gold -= cost
        keeper.gold += cost

        if item.flags.inventory:
            item = object_creator.create_item(
                instance.item_templates[item.vnum], item.level)
        else:
            item.in_living.get(item)
        ch.put(item)
示例#15
0
def do_clone(ch, argument):
    rest, arg = game_utils.read_word(argument)
    mob = None
    obj = None
    if not arg:
        ch.send("Clone what?\n")
        return
    if "object".startswith(arg):
        mob = None
        obj = ch.get_item_here(rest)
        if not obj:
            ch.send("You don't see that here.\n")
            return
    elif "character".startswith(arg) or "mobile".startswith(arg):
        obj = None
        mob = ch.get_char_room(rest)
        if not mob:
            ch.send("You don't see that here.\n")
            return
    else:  # find both
        mob = ch.get_char_room(argument)
        obj = ch.get_item_here(argument)
        if mob is None and obj is None:
            ch.send("You don't see that here.\n")
            return
            # clone an object
    if obj:
        if not handler_item.item_check(ch, obj):
            ch.send("Your powers are not great enough for such a task.\n")
            return
        clone = object_creator.create_item(obj.vnum, 0)
        object_creator.clone_item(obj, clone)
        if obj.in_living:
            clone.put(ch)
        else:
            clone.put(ch.in_room)
        handler_item.recursive_clone(ch, obj, clone)

        handler_game.act("$n has created $p.", ch, clone, None, merc.TO_ROOM)
        handler_game.act("You clone $p.", ch, clone, None, merc.TO_CHAR)
        handler_game.wiznet("$N clones $p.", ch, clone, merc.WIZ_LOAD,
                            merc.WIZ_SECURE, ch.trust)
        return
    elif mob:
        if not state_checks.IS_NPC(mob):
            ch.send("You can only clone mobiles.\n")
            return
        if (mob.level > 20 and not state_checks.IS_TRUSTED(ch, merc.L4)) \
                or (mob.level > 10 and not state_checks.IS_TRUSTED(ch, merc.L5)) \
                or (mob.level > 5 and not state_checks.IS_TRUSTED(ch, merc.L6)) \
                or (mob.level > 0 and not state_checks.IS_TRUSTED(ch, merc.L7)) \
                or not state_checks.IS_TRUSTED(ch, merc.L8):
            ch.send("Your powers are not great enough for such a task.\n")
            return
        clone = object_creator.create_mobile(mob.vnum)
        object_creator.clone_mobile(mob, clone)

        for obj in mob.contents:
            if handler_item.item_check(ch, obj):
                new_obj = object_creator.create_item(obj.vnum, 0)
                object_creator.clone_item(obj, new_obj)
                handler_item.recursive_clone(ch, obj, new_obj)
                new_obj.put(clone)
                new_obj.equips_to = obj.equips_to
        clone.put(ch.in_room)
        handler_game.act("$n has created $N.", ch, None, clone, merc.TO_ROOM)
        handler_game.act("You clone $N.", ch, None, clone, merc.TO_CHAR)
        handler_game.wiznet("$N clones %s." % clone.short_descr, ch, None,
                            merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust)
        return
示例#16
0
def room_text(ch, argument):
    for rt in ch.in_room.roomtext:
        if game_utils.str_cmp(argument, rt.input) or game_utils.is_in(argument, rt.input) or game_utils.all_in(argument, rt.input):
            if rt.name and not game_utils.str_cmp(rt.name, ["all", "|all*"]):
                if not game_utils.is_in(ch.name, rt.name):
                    continue

            mobfound = True
            if rt.mob != 0:
                mobfound = False
                for vch_id in ch.in_room.people[:]:
                    vch = instance.characters[vch_id]

                    if not vch.is_npc():
                        continue

                    if vch.vnum == rt.mob:
                        mobfound = True
                        break

            if not mobfound:
                continue

            hop = False
            rtype = rt.type % merc.RT_RETURN
            if rtype == merc.RT_SAY:
                pass
            elif rtype == merc.RT_LIGHTS:
                ch.cmd_changelight("")
            elif rtype == merc.RT_LIGHT:
                ch.in_room.room_flags.rem_bit(merc.ROOM_DARK)
            elif rtype == merc.RT_DARK:
                ch.in_room.room_flags.set_bit(merc.ROOM_DARK)
            elif rtype == merc.RT_OBJECT:
                obj_index = instance.item_templates[rt.power]
                if not obj_index:
                    return

                item = object_creator.create_item(obj_index, ch.level)

                if state_checks.is_set(rt.type, merc.RT_TIMER):
                    item.timer = 1

                if item.flags.take:
                    ch.put(item)
                else:
                    ch.in_room.put(item)

                if game_utils.str_cmp(rt.choutput, "copy"):
                    handler_game.act(rt.output, ch, item, None, merc.TO_CHAR)
                else:
                    handler_game.act(rt.choutput, ch, item, None, merc.TO_CHAR)

                if not state_checks.is_set(rt.type, merc.RT_PERSONAL):
                    handler_game.act(rt.output, ch, item, None, merc.TO_ROOM)
                hop = True
            elif rtype == merc.RT_MOBILE:
                mob_index = instance.npc_templates[rt.power]
                if not mob_index:
                    return

                mob = object_creator.create_mobile(mob_index)
                ch.in_room.put(mob)

                if game_utils.str_cmp(rt.choutput, "copy"):
                    handler_game.act(rt.output, ch, None, mob, merc.TO_CHAR)
                else:
                    handler_game.act(rt.choutput, ch, None, mob, merc.TO_CHAR)

                if not state_checks.is_set(rt.type, merc.RT_PERSONAL):
                    handler_game.act(rt.output, ch, None, mob, merc.TO_ROOM)
                hop = True
            elif rtype == merc.RT_SPELL:
                const.skill_table[rt.power].spell_fun(rt.power, game_utils.number_range(20, 30), ch, ch, merc.TARGET_CHAR)
            elif rtype == merc.RT_PORTAL:
                if merc.OBJ_VNUM_PORTAL not in instance.item_templates:
                    return

                item = object_creator.create_item(instance.item_templates[merc.OBJ_VNUM_PORTAL], 0)
                item.timer = 1
                item.value[0] = rt.power
                item.value[1] = 1
                ch.in_room.put(item)
            elif rtype == merc.RT_TELEPORT:
                room = instance.rooms[rt.power]
                if not room:
                    return

                if game_utils.str_cmp(rt.choutput, "copy"):
                    handler_game.act(rt.output, ch, None, None, merc.TO_CHAR)
                else:
                    handler_game.act(rt.choutput, ch, None, None, merc.TO_CHAR)

                if not state_checks.is_set(rt.type, merc.RT_PERSONAL):
                    handler_game.act(rt.output, ch, None, None, merc.TO_ROOM)
                ch.in_room.get(ch)
                room.put(ch)
                handler_game.act("$n appears in the room.", ch, None, None, merc.TO_ROOM)
                ch.cmd_look("auto")
                hop = True
            elif rtype == merc.RT_ACTION:
                arg = argument
                argument, arg1 = game_utils.read_word(arg)
                argument, arg2 = game_utils.read_word(arg)

                mob = ch.get_char_room(arg2)
                if not mob:
                    return

                mob.interpret(rt.output)
            elif rtype == merc.RT_OPEN_LIFT:
                open_lift(ch)
            elif rtype == merc.RT_CLOSE_LIFT:
                close_lift(ch)
            elif rtype == merc.RT_MOVE_LIFT:
                move_lift(ch, rt.power)

            if hop and state_checks.is_set(rt.type, merc.RT_RETURN):
                return
            elif hop:
                continue

            if game_utils.str_cmp(rt.choutput, "copy") and not state_checks.is_set(rt.type, merc.RT_ACTION):
                handler_game.act(rt.output, ch, None, None, merc.TO_CHAR)
            elif not state_checks.is_set(rt.type, merc.RT_ACTION):
                handler_game.act(rt.choutput, ch, None, None, merc.TO_CHAR)

            if not state_checks.is_set(rt.type, merc.RT_PERSONAL) and not state_checks.is_set(rt.type, merc.RT_ACTION):
                handler_game.act(rt.output, ch, None, None, merc.TO_ROOM)

            if state_checks.is_set(rt.type, merc.RT_RETURN):
                return
示例#17
0
def do_clone(ch, argument):
    rest, arg = game_utils.read_word(argument)
    mob = None
    obj = None
    if not arg:
        ch.send("Clone what?\n")
        return
    if "object".startswith(arg):
        mob = None
        obj = ch.get_item_here(rest)
        if not obj:
            ch.send("You don't see that here.\n")
            return
    elif "character".startswith(arg) or "mobile".startswith(arg):
        obj = None
        mob = ch.get_char_room(rest)
        if not mob:
            ch.send("You don't see that here.\n")
            return
    else:  # find both
        mob = ch.get_char_room(argument)
        obj = ch.get_item_here(argument)
        if mob is None and obj is None:
            ch.send("You don't see that here.\n")
            return
            # clone an object
    if obj:
        if not handler_item.item_check(ch, obj):
            ch.send("Your powers are not great enough for such a task.\n")
            return
        clone = object_creator.create_item(obj.vnum, 0)
        object_creator.clone_item(obj, clone)
        if obj.in_living:
            clone.put(ch)
        else:
            clone.put(ch.in_room)
        handler_item.recursive_clone(ch, obj, clone)

        handler_game.act("$n has created $p.", ch, clone, None, merc.TO_ROOM)
        handler_game.act("You clone $p.", ch, clone, None, merc.TO_CHAR)
        handler_game.wiznet("$N clones $p.", ch, clone, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust)
        return
    elif mob:
        if not state_checks.IS_NPC(mob):
            ch.send("You can only clone mobiles.\n")
            return
        if (mob.level > 20 and not state_checks.IS_TRUSTED(ch, merc.L4)) \
                or (mob.level > 10 and not state_checks.IS_TRUSTED(ch, merc.L5)) \
                or (mob.level > 5 and not state_checks.IS_TRUSTED(ch, merc.L6)) \
                or (mob.level > 0 and not state_checks.IS_TRUSTED(ch, merc.L7)) \
                or not state_checks.IS_TRUSTED(ch, merc.L8):
            ch.send("Your powers are not great enough for such a task.\n")
            return
        clone = object_creator.create_mobile(mob.vnum)
        object_creator.clone_mobile(mob, clone)

        for obj in mob.contents:
            if handler_item.item_check(ch, obj):
                new_obj = object_creator.create_item(obj.vnum, 0)
                object_creator.clone_item(obj, new_obj)
                handler_item.recursive_clone(ch, obj, new_obj)
                new_obj.put(clone)
                new_obj.equips_to = obj.equips_to
        clone.put(ch.in_room)
        handler_game.act("$n has created $N.", ch, None, clone, merc.TO_ROOM)
        handler_game.act("You clone $N.", ch, None, clone, merc.TO_CHAR)
        handler_game.wiznet("$N clones %s." % clone.short_descr, ch, None, merc.WIZ_LOAD, merc.WIZ_SECURE, ch.trust)
        return