Example #1
0
def item_check(ch, obj):
    #TODO add real values, just guessed for now
    if state_checks.IS_TRUSTED(ch, 60) \
            or (state_checks.IS_TRUSTED(ch, 55) and obj.level <= 20 and obj.cost <= 1000) \
            or (state_checks.IS_TRUSTED(ch, 53) and obj.level <= 10 and obj.cost <= 500) \
            or (state_checks.IS_TRUSTED(ch, 52) and obj.level <= 5 and obj.cost <= 250) \
            or (state_checks.IS_TRUSTED(ch, 51) and obj.level == 0 and obj.cost <= 100):
        return True
    else:
        return False
Example #2
0
def do_force(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg or not argument:
        ch.send("Force whom to do what?\n")
        return
    temp, arg2 = game_utils.read_word(argument)
    if arg2 == "delete":
        ch.send("That will NOT be done.\n")
        return
    buf = "$n forces you to '%s'." % argument
    if arg == "all":
        if ch.trust < merc.MAX_LEVEL - 3:
            ch.send("Not at your level!\n")
            return
        for vch in instance.characters.values():
            if not vch.is_npc() and vch.trust < ch.trust:
                handler_game.act(buf, ch, None, vch, merc.TO_VICT)
                vch.interpret(argument)
    elif arg == "players":
        if ch.trust < merc.MAX_LEVEL - 2:
            ch.send("Not at your level!\n")
            return
        for vch in instance.characters.values():
            if not vch.is_npc(
            ) and vch.trust < ch.trust and vch.level < merc.LEVEL_HERO:
                handler_game.act(buf, ch, None, vch, merc.TO_VICT)
                vch.interpret(argument)
    elif arg == "gods":
        if ch.trust < merc.MAX_LEVEL - 2:
            ch.send("Not at your level!\n")
            return
        for vch in instance.characters.values():
            if not vch.is_npc(
            ) and vch.trust < ch.trust and vch.level >= merc.LEVEL_HERO:
                handler_game.act(buf, ch, None, vch, merc.TO_VICT)
                vch.interpret(argument)
    else:
        victim = ch.get_char_world(arg)
        if not victim:
            ch.send("They aren't here.\n")
            return
        if victim == ch:
            ch.send("Aye aye, right away!\n")
            return
        if not ch.is_room_owner(victim.in_room) and ch.in_room != victim.in_room \
                and victim.in_room.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL):
            ch.send("That character is in a private room.\n")
            return
        if victim.is_pc() and victim.trust >= ch.trust:
            ch.send("Do it yourself!\n")
            return
        if not victim.is_npc() and ch.trust < merc.MAX_LEVEL - 3:
            ch.send("Not at your level!\n")
            return
        handler_game.act(buf, ch, None, victim, merc.TO_VICT)
        #TODO: Known broken. NPCs don't have interpret, so we'll have to figure this out.
        victim.interpret(argument)
    ch.send("Ok.\n")
    return
Example #3
0
def do_rstat(ch, argument):
    argument, arg = game_utils.read_word(argument)
    location = ch.in_room if not arg else game_utils.find_location(ch, arg)
    if not location:
        ch.send("No such location.\n")
        return

    if not ch.is_room_owner(location) and ch.in_room != location \
            and location.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL):
        ch.send("That room is private right now.\n")
        return
    ch.send("Name: '%s'\nArea: '%s'\n" % (location.name, location.area))
    ch.send("Vnum: %d  Sector: %d  Light: %d  Healing: %d  Mana: %d\n" %
            (location.vnum, location.sector_type, location.available_light,
             location.heal_rate, location.mana_rate))
    ch.send("Room flags: %d.\nDescription:\n%s" %
            (location.room_flags, location.description))
    if location.extra_descr:
        ch.send("Extra description keywords: '")
        [ch.send(ed.keyword + " ") for ed in location.extra_descr]
        ch.send("'.\n")

    ch.send("Characters:")
    for rch_id in location.people:
        rch = instance.characters[rch_id]
        if ch.can_see(rch):
            ch.send("%s " % rch.name if not rch.is_npc() else rch.short_descr)
    ch.send(".\nObjects:   ")
    for obj_id in location.inventory[:]:
        obj = instance.global_instances[obj_id]
        ch.send("'%s' " % obj.name)
    ch.send(".\n")
    for door, pexit in enumerate(location.exit):
        if pexit:
            ch.send(
                "Door: %d.  To: %d.  Key: %d.  Exit flags: %d.\nKeyword: '%s'.  Description: %s"
                % (
                    door,  # TODO:  come back and fix this
                    -1 if pexit.to_room is None else
                    instance.rooms[pexit.to_room].vnum,
                    -1 if pexit.key is None else pexit.key,
                    pexit.exit_info,
                    pexit.keyword,
                    pexit.description if pexit.description else "(none).\n"))
    return
Example #4
0
def do_snoop(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Snoop whom?\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if not victim.desc:
        ch.send("No descriptor to snoop.\n")
        return
    if victim == ch:
        ch.send("Cancelling all snoops.\n")
        handler_game.wiznet("$N stops being such a snoop.", ch, None,
                            merc.WIZ_SNOOPS, merc.WIZ_SECURE, ch.trust)
        for d in merc.descriptor_list:
            if d.snoop_by == ch.desc:
                d.snoop_by = None
        return
    if victim.desc.snoop_by:
        ch.send("Busy already.\n")
        return
    if not ch.is_room_owner(victim.in_room) and ch.in_room != victim.in_room \
            and victim.in_room.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL):
        ch.send("That character is in a private room.\n")
        return
    if victim.trust >= ch.trust or victim.comm.is_set(merc.COMM_SNOOP_PROOF):
        ch.send("You failed.\n")
        return
    if ch.desc:
        d = ch.desc.snoop_by
        while d:
            if d.character == victim or d.original == victim:
                ch.send("No snoop loops.\n")
                return
            d = d.snoop_by
    victim.desc.snoop_by = ch.desc
    buf = "$N starts snooping on %s" % (victim.short_descr
                                        if ch.is_npc() else victim.name)
    handler_game.wiznet(buf, ch, None, merc.WIZ_SNOOPS, merc.WIZ_SECURE,
                        ch.trust)
    ch.send("Ok.\n")
    return
Example #5
0
def do_switch(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Switch into whom?\n")
        return
    if not ch.desc is None:
        return
    if ch.desc.original:
        ch.send("You are already switched.\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim == ch:
        ch.send("Ok.\n")
        return
    if not victim.is_npc():
        ch.send("You can only switch into mobiles.\n")
        return
    if not ch.is_room_owner(victim.in_room) and ch.in_room != victim.in_room \
            and victim.in_room.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL):
        ch.send("That character is in a private room.\n")
        return
    if victim.desc:
        ch.send("Character in use.\n")
        return

    handler_game.wiznet("$N switches into %s" % victim.short_descr, ch, None,
                        merc.WIZ_SWITCHES, merc.WIZ_SECURE, ch.trust)

    ch.desc.character = victim
    ch.desc.original = ch
    victim.desc = ch.desc
    ch.desc = None
    # change communications to match
    if ch.prompt:
        victim.prompt = ch.prompt
    victim.comm = ch.comm
    victim.lines = ch.lines
    victim.send("Ok.\n")
    return
Example #6
0
def do_enter(ch, argument):
    if ch.fighting:
        return
    # nifty portal stuff
    if argument:
        old_room = ch.in_room
        portal = ch.get_item_list(argument, ch.in_room.items)
        if not portal:
            ch.send("You don't see that here.\n")
            return
        if portal.item_type != merc.ITEM_PORTAL \
                or (state_checks.IS_SET(portal.value[1], merc.EX_CLOSED) and not state_checks.IS_TRUSTED(ch, merc.L7)):
            ch.send("You can't seem to find a way in.\n")
            return
        if not state_checks.IS_TRUSTED(ch, merc.L7) and not state_checks.IS_SET(portal.value[2], merc.GATE_NOCURSE) \
                and (ch.is_affected(merc.AFF_CURSE) or state_checks.IS_SET(old_room.room_flags, merc.ROOM_NO_RECALL)):
            ch.send("Something prevents you from leaving...\n")
            return
        location = None
        if state_checks.IS_SET(portal.value[2],
                               merc.GATE_RANDOM) or portal.value[3] == -1:
            location = handler_room.get_random_room(ch)
            portal.value[3] = location.vnum  # for record keeping :)
        elif state_checks.IS_SET(
                portal.value[2],
                merc.GATE_BUGGY) and (random.randint(1, 99) < 5):
            location = handler_room.get_random_room(ch)
        else:
            location = instance.rooms[portal.value[3]]
        if not location or location == old_room \
                or not  ch.can_see_room(location.instance_id) \
                or (location.is_private() and not state_checks.IS_TRUSTED(ch, merc.MAX_LEVEL)):
            handler_game.act("$p doesn't seem to go anywhere.", ch, portal,
                             None, merc.TO_CHAR)
            return
        if ch.is_npc() and ch.act.is_set(merc.ACT_AGGRESSIVE) \
                and state_checks.IS_SET(location.room_flags, merc.ROOM_LAW):
            ch.send("Something prevents you from leaving...\n")
            return
        handler_game.act("$n steps into $p.", ch, portal, None, merc.TO_ROOM)

        if state_checks.IS_SET(portal.value[2], merc.GATE_NORMAL_EXIT):
            handler_game.act("You enter $p.", ch, portal, None, merc.TO_CHAR)
        else:
            handler_game.act(
                "You walk through $p and find yourself somewhere else:...", ch,
                portal, None, merc.TO_CHAR)
        ch.in_room.get(ch)
        location.put(ch)
        if state_checks.IS_SET(portal.value[2],
                               merc.GATE_GOWITH):  # take the gate along
            portal.get()
            portal.put(location)
        if state_checks.IS_SET(portal.value[2], merc.GATE_NORMAL_EXIT):
            handler_game.act("$n has arrived.", ch, portal, None, merc.TO_ROOM)
        else:
            handler_game.act("$n has arrived through $p.", ch, portal, None,
                             merc.TO_ROOM)

        ch.do_look("auto")
        # charges
        if portal.value[0] > 0:
            portal.value[0] -= 1
            if portal.value[0] == 0:
                portal.value[0] = -1
        # protect against circular follows
        if old_room == location:
            return
        for fch_id in old_room.people[:]:
            fch = instance.characters[fch_id]
            if not portal or portal.value[0] == -1:
                # no following through dead portals
                continue
            if fch.master == ch and state_checks.IS_AFFECTED(fch, merc.AFF_CHARM) \
                    and fch.position < merc.POS_STANDING:
                fch.do_stand("")
            if fch.master == ch and fch.position == merc.POS_STANDING:
                if state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_LAW) \
                        and (state_checks.IS_NPC(fch) and fch.act.is_set(merc.ACT_AGGRESSIVE)):
                    handler_game.act("You can't bring $N into the city.", ch,
                                     None, fch, merc.TO_CHAR)
                    handler_game.act("You aren't allowed in the city.", fch,
                                     None, None, merc.TO_CHAR)
                    continue
                handler_game.act("You follow $N.", fch, None, ch, merc.TO_CHAR)
                fch.do_enter(argument)
        if portal and portal.value[0] == -1:
            handler_game.act("$p fades out of existence.", ch, portal, None,
                             merc.TO_CHAR)
            if ch.in_room == old_room:
                handler_game.act("$p fades out of existence.", ch, portal,
                                 None, merc.TO_ROOM)
            elif old_room.people:
                handler_game.act("$p fades out of existence.", old_room.people,
                                 portal, None, merc.TO_CHAR)
                handler_game.act("$p fades out of existence.", old_room.people,
                                 portal, None, merc.TO_ROOM)
            portal.extract()
        return
    ch.send("Nope, can't do it.\n")
    return
Example #7
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