Exemplo n.º 1
0
def cmd_wake(ch, cmd, arg):
    '''If sleep, attempts to wake up and sit.'''
    mud.message(ch, None, None, None, True, "to_char",
                "You stop sleeping and sit up.")
    mud.message(ch, None, None, None, True, "to_room",
                "$n stops sleeping and sits up.")
    ch.pos = "sitting"
Exemplo n.º 2
0
def cmd_goto(ch, cmd, arg):
    '''Usage: goto <person | place | thing>

       Transfer yourself to a specified room, object, or person in game. Rooms
       are referenced by their zone key.
       '''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg,
                                     "{ room ch.world.noself }")
    except:
        return

    # what did we find?
    if type == "char":
        dest = found.room
    else:
        dest = found

    mud.message(ch, None, None, None, True, "to_room",
                "$n disappears in a puff of smoke.")
    ch.room = dest
    ch.act("look")
    mud.message(ch, None, None, None, True, "to_room",
                "$n appears in a puff of smoke.")
    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
Exemplo n.º 3
0
def cmd_wake(ch, cmd, arg):
    '''If sleep, attempts to wake up and sit.'''
    mud.message(ch,None,None,None,True, "to_char",
                "You stop sleeping and sit up.")
    mud.message(ch,None,None,None,True, "to_room",
                "$n stops sleeping and sits up.")
    ch.pos = "sitting"
Exemplo n.º 4
0
def do_drop(ch, obj):
    '''handles object dropping'''
    obj.room = ch.room

    mud.message(ch, None, obj, None, True, "to_char", "You drop $o.")
    mud.message(ch, None, obj, None, True, "to_room", "$n drops $o.")

    # run our drop hook
    hooks.run("drop", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 5
0
def do_drop(ch, obj):
    '''handles object dropping'''
    obj.room = ch.room

    mud.message(ch, None, obj, None, True, "to_char", "You drop $o.")
    mud.message(ch, None, obj, None, True, "to_room", "$n drops $o.")

    # run our drop hook
    hooks.run("drop", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 6
0
def do_wear(ch, obj, where):
    '''handles object wearing'''
    if not obj.istype("worn"):
        ch.send("But " + ch.see_as(obj) + " is not equippable.")
        
    elif ch.equip(obj, where):
        mud.message(ch, None, obj, None, True, "to_char", "You wear $o.")
        mud.message(ch, None, obj, None, True, "to_room", "$n wears $o.")

        # run our wear hook
        hooks.run("wear", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 7
0
def do_wear(ch, obj, where):
    '''handles object wearing'''
    if not obj.istype("worn"):
        ch.send("But " + ch.see_as(obj) + " is not equippable.")

    elif ch.equip(obj, where):
        mud.message(ch, None, obj, None, True, "to_char", "You wear $o.")
        mud.message(ch, None, obj, None, True, "to_room", "$n wears $o.")

        # run our wear hook
        hooks.run("wear", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 8
0
def cmd_gemote(ch, cmd, arg):
    '''Gemote is similar to emote, except that it sends a mud-wide message
       instead of a room-specific message.'''
    if arg == '':
        ch.send("Gemote we must, but gemote what?")
    else:
        # same as emote, but global
        if arg.find("$n") == -1:
            arg = "$n " + arg
        mud.message(ch, None, None, None, False, "to_world, to_char",
                    "{bGLOBAL:{c " + arg + "{n")
Exemplo n.º 9
0
def cmd_gemote(ch, cmd, arg):
    '''Gemote is similar to emote, except that it sends a mud-wide message
       instead of a room-specific message.'''
    if arg == '':
        ch.send("Gemote we must, but gemote what?")
    else:
        # same as emote, but global
        if arg.find("$n") == -1:
            arg = "$n " + arg
        mud.message(ch, None, None, None, False, "to_world, to_char",
                    "{bGLOBAL:{c " + arg + "{n")
Exemplo n.º 10
0
def do_transfer(ch, tgt, dest):
    '''ch transfers tgt to dest'''
    if tgt.room == dest:
        ch.send(ch.see_as(tgt) + " is already there")
    else:
        tgt.send(tgt.see_as(ch) + " has transferred you to " + dest.name)
        mud.message(tgt, None, None, None, True, "to_room",
                    "$n disappears in a puff of smoke.")
        tgt.room = dest
        tgt.act("look", False)
        mud.message(tgt, None, None, None, True, "to_room",
                    "$n arrives in a puff of smoke.")
Exemplo n.º 11
0
def do_transfer(ch, tgt, dest):
    '''ch transfers tgt to dest'''
    if tgt.room == dest:
        ch.send(ch.see_as(tgt) + " is already there")
    else:
        tgt.send(tgt.see_as(ch) + " has transferred you to " + dest.name)
        mud.message(tgt, None, None, None, True, "to_room",
                    "$n disappears in a puff of smoke.")
        tgt.room = dest
        tgt.act("look", False)
        mud.message(tgt, None, None, None, True, "to_room",
                    "$n arrives in a puff of smoke.")
Exemplo n.º 12
0
def cmd_chat(ch, cmd, arg):
    '''Usage: chat <message>

       This command will send a message to all players currently logged on.
       '''
    if arg == '':
        ch.send("Chat what?")
    else:
        arg  = arg.replace("$", "$$")
        mssg = "{y$n chats, '" + arg + "'{n"
        mud.message(ch, None, None, None, False, "to_world", mssg)
        mud.message(ch, None, None, None,False,"to_char", "{yyou chat, '"+arg+"'{n")
        history.add_history(ch, "chat", "{y%-10s: %s{n" % (ch.name, arg))
Exemplo n.º 13
0
def do_put(ch, obj, cont):
    '''handles the putting of objects'''
    if obj == cont:
        ch.send("You cannot put " + ch.see_as(obj) + " into itself.")
    # make sure we have enough room
    elif obj.weight > cont.container_capacity - cont.weight + cont.weight_raw:
        ch.send("There is not enough room in " + ch.see_as(cont) + " for " +
                ch.see_as(obj) + ".")
    # do the move
    else:
        obj.container = cont
        mud.message(ch, None, obj, cont, True, "to_char", "You put $o in $O.")
        mud.message(ch, None, obj, cont, True, "to_room", "$n puts $o in $O.")
Exemplo n.º 14
0
def do_put(ch, obj, cont):
    '''handles the putting of objects'''
    if obj == cont:
        ch.send("You cannot put " + ch.see_as(obj) + " into itself.")
    # make sure we have enough room 
    elif obj.weight > cont.container_capacity - cont.weight + cont.weight_raw:
        ch.send("There is not enough room in " + ch.see_as(cont) +
                " for " + ch.see_as(obj) + ".")
    # do the move
    else:
        obj.container = cont
        mud.message(ch, None, obj, cont, True, "to_char", "You put $o in $O.")
        mud.message(ch, None, obj, cont, True, "to_room", "$n puts $o in $O.")
Exemplo n.º 15
0
def cmd_chat(ch, cmd, arg):
    '''Usage: chat <message>

       This command will send a message to all players currently logged on.
       '''
    if arg == '':
        ch.send("Chat what?")
    else:
        arg  = arg.replace("$", "$$")
        mssg = "{y$n chats, '" + arg + "'{n"
        mud.message(ch, None, None, None, False, "to_world", mssg)
        mud.message(ch, None, None, None,False,"to_char", "{yyou chat, '"+arg+"'{n")
        history.add_history(ch, "chat", "{y%-10s: %s{n" % (ch.name, arg))
Exemplo n.º 16
0
def do_remove(ch, obj):
    '''handles equipment removing'''
    # try to put it to our inventory
    obj.carrier = ch

    # make sure it succeeded
    if obj.carrier != ch:
        ch.send("You were unable to remove " + ch.see_as(obj) + ".")
    else:
        mud.message(ch, None, obj, None, True, "to_char", "You remove $o.")
        mud.message(ch, None, obj, None, True, "to_room", "$n removes $o.")

        # run our hooks
        hooks.run("remove", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 17
0
def do_remove(ch, obj):
    '''handles equipment removing'''
    # try to put it to our inventory
    obj.carrier = ch

    # make sure it succeeded
    if obj.carrier != ch:
        ch.send("You were unable to remove " + ch.see_as(obj) + ".")
    else:
        mud.message(ch, None, obj, None, True, "to_char", "You remove $o.")
        mud.message(ch, None, obj, None, True, "to_room", "$n removes $o.")

        # run our hooks
        hooks.run("remove", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 18
0
def try_use_furniture(ch, obj, pos):
    '''attempts to resituate a person on the piece of furniture'''
    # are we already on it?
    if ch.on == obj:
        ch.send("You are already " + ch.on.furniture_type + " " + ch.on.name +
                ".")
    # make sure we have room
    elif obj.furniture_capacity <= len(obj.chars):
        ch.send("There isn't any room left.")
    else:
        # are we already on something? get up first
        if ch.on:
            mud.message(ch, None, ch.on, None, True, "to_char",
                        "You stand up from $o.")
            mud.message(ch, None, ch.on, None, True, "to_room",
                        "$n stands up from $o.")
            ch.on = None

        # send our mud.messages for sitting down
        act = pos_act[positions.index(pos)]
        mud.message(ch, None, obj, None, True, "to_char",
                    "You " + act + " " + obj.furniture_type + " $o.")
        mud.message(ch, None, obj, None, True, "to_room",
                    "$n " + act + " " + obj.furniture_type + " $o.")

        # place ourselves down on our new furniture
        ch.on = obj
        ch.pos = pos
        return True

    # we didn't manage to get on the furniture
    return False
Exemplo n.º 19
0
def try_use_furniture(ch, obj, pos):
    '''attempts to resituate a person on the piece of furniture'''
    # are we already on it?
    if ch.on == obj:
        ch.send("You are already " +ch.on.furniture_type+ " " +ch.on.name+ ".")
    # make sure we have room
    elif obj.furniture_capacity <= len(obj.chars):
        ch.send("There isn't any room left.")
    else:
        # are we already on something? get up first
        if ch.on:
            mud.message(ch,None,ch.on,None,True,"to_char",
                        "You stand up from $o.")
            mud.message(ch,None,ch.on,None,True,"to_room",
                        "$n stands up from $o.")
            ch.on = None

        # send our mud.messages for sitting down
        act = pos_act[positions.index(pos)]
        mud.message(ch, None, obj, None, True,
                    "to_char", "You " + act + " " + obj.furniture_type + " $o.")
        mud.message(ch, None, obj, None, True,
                    "to_room", "$n " + act + " " + obj.furniture_type + " $o.")

        # place ourselves down on our new furniture
        ch.on  = obj
        ch.pos = pos
        return True

    # we didn't manage to get on the furniture
    return False
Exemplo n.º 20
0
def cmd_say(ch, cmd, arg):
    '''Usage: say <message>

      This command will send a message to everyone in the same room as you. Say,
      like ask, can trigger NPC dialogs.'''
    if arg == '':
        ch.send("Say what?")
    else:
        arg = arg.replace("$", "$$")
        mud.message(ch, None, None, None, False, "to_room",
                    "{y$n says, '" + arg + "'{n")
        mud.message(ch, None, None, None, False, "to_char",
                    "{yyou say, '" + arg + "'{n")        

        # run say hooks
        hooks.run("say", hooks.build_info("ch str", (ch, arg)))
Exemplo n.º 21
0
def cmd_say(ch, cmd, arg):
    '''Usage: say <message>

      This command will send a message to everyone in the same room as you. Say,
      like ask, can trigger NPC dialogs.'''
    if arg == '':
        ch.send("Say what?")
    else:
        arg = arg.replace("$", "$$")
        mud.message(ch, None, None, None, False, "to_room",
                    "{y$n says, '" + arg + "'{n")
        mud.message(ch, None, None, None, False, "to_char",
                    "{yyou say, '" + arg + "'{n")        

        # run say hooks
        hooks.run("say", hooks.build_info("ch str", (ch, arg)))
Exemplo n.º 22
0
def cmd_unlock(ch, cmd, arg):
    '''Usage: unlock <door | direction | container>

       Attempts to unlock the specified door, direction, or container.'''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg,
                                     "[the] {obj.room.inv exit }")
    except:
        return

    # what did we find?
    if type == "exit":
        ex = found
        name = ex.name
        if ex.name == "":
            name = "the exit"

        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif not ex.is_locked:
            ch.send(name + " is already unlocked.")
        elif ex.key == '':
            ch.send("You cannot figure out how " + name +
                    " would be unlocked.")
        elif not has_proto(ch, ex.key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You unlock " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n unlocks " + name + ".")
            ex.unlock()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, ex.is_closed, False)

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif not obj.container_is_locked:
            ch.send(ch.see_as(obj) + " is already unlocked.")
        elif obj.container_key == '':
            ch.send("You cannot figure out how to unlock " + ch.see_as(obj))
        elif not has_proto(ch, obj.container_key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You unlock $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n unlocks $o.")
            obj.container_is_locked = False
Exemplo n.º 23
0
def cmd_emote(ch, cmd, arg):
    '''Usage: emote <text>

       Send a special text message to the room you are in. The message is
       preceded by your name, unless you put a $n somewhere in the text, in
       which case the $n is replaced by your name. For example:

       > emote A gunshot sounds, and $n is laying on the ground, dead.

       Would show a message to everyone in the room saying that you are dead
       to a gunshot.'''
    if arg == '':
        ch.send("Emote we must, but emote what?")
    else:
        # see if a $n is within the argument ... if there is, let the person
        # put his or her name where it's wanted. Otherwise, tag it onto the
        # front of the message
        if arg.find("$n") == -1:
            arg = "$n " + arg
        mud.message(ch, None, None, None, False, "to_room, to_char", arg)
Exemplo n.º 24
0
def cmd_emote(ch, cmd, arg):
    '''Usage: emote <text>

       Send a special text message to the room you are in. The message is
       preceded by your name, unless you put a $n somewhere in the text, in
       which case the $n is replaced by your name. For example:

       > emote A gunshot sounds, and $n is laying on the ground, dead.

       Would show a message to everyone in the room saying that you are dead
       to a gunshot.'''
    if arg == '':
        ch.send("Emote we must, but emote what?")
    else:
        # see if a $n is within the argument ... if there is, let the person
        # put his or her name where it's wanted. Otherwise, tag it onto the
        # front of the message
        if arg.find("$n") == -1:
            arg = "$n " + arg
        mud.message(ch, None, None, None, False, "to_room, to_char", arg)
Exemplo n.º 25
0
def cmd_tell(ch, cmd, arg):
    '''Usage: tell <person> <message>

       This command sends a message to another character. Primarily intended
       for player-to-player communication. Players can tell other players
       things even if they are not in the same room.

       see also: reply'''
    try:
        tgt, mssg = mud.parse_args(ch, True, cmd, arg,
                                   "ch.world.noself string(message)")
    except: return

    mssg   = mssg.replace("$", "$$")
    tovict = "{r$n tells you, '" + mssg + "'{n"
    toch   = "{rYou tell $N, '" + mssg + "'{n"
    mud.message(ch, tgt, None, None, False, "to_vict", tovict)
    mud.message(ch, tgt, None, None, False, "to_char", toch)
    history.add_history(ch,   "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    history.add_history(tgt,  "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    hooks.run("tell", hooks.build_info("ch ch str", (ch, tgt, mssg)))
Exemplo n.º 26
0
def cmd_tell(ch, cmd, arg):
    '''Usage: tell <person> <message>

       This command sends a message to another character. Primarily intended
       for player-to-player communication. Players can tell other players
       things even if they are not in the same room.

       see also: reply'''
    try:
        tgt, mssg = mud.parse_args(ch, True, cmd, arg,
                                   "ch.world.noself string(message)")
    except: return

    mssg   = mssg.replace("$", "$$")
    tovict = "{r$n tells you, '" + mssg + "'{n"
    toch   = "{rYou tell $N, '" + mssg + "'{n"
    mud.message(ch, tgt, None, None, False, "to_vict", tovict)
    mud.message(ch, tgt, None, None, False, "to_char", toch)
    history.add_history(ch,   "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    history.add_history(tgt,  "tell", "{r%-10s: %s{n" % (ch.name, mssg))
    hooks.run("tell", hooks.build_info("ch ch str", (ch, tgt, mssg)))
Exemplo n.º 27
0
def cmd_ask(ch, cmd, arg):
    '''Usage: ask <person> [about] <question>

       This command is used to pose a question to another character. Mostly,
       this is intended to be used to carry on dialogs with NPCs. Ask has a
       local range (i.e. you can only ask questions to people in the same room
       as you.
       '''
    try:
        tgt, question =mud.parse_args(ch, True, cmd, arg,
                                      "ch.room.noself [about] string(question)")
    except: return

    question = question.replace("$", "$$")
    mud.message(ch, tgt, None, None, False, "to_vict",
                "{w$n asks you, '" + question + "'{n")
    mud.message(ch, tgt, None, None, False, "to_char",
                "{wYou ask $N, '" + question + "'{n")

    # run our ask hooks
    hooks.run("ask", hooks.build_info("ch ch str", (ch, tgt, question)))
Exemplo n.º 28
0
def cmd_ask(ch, cmd, arg):
    '''Usage: ask <person> [about] <question>

       This command is used to pose a question to another character. Mostly,
       this is intended to be used to carry on dialogs with NPCs. Ask has a
       local range (i.e. you can only ask questions to people in the same room
       as you.
       '''
    try:
        tgt, question =mud.parse_args(ch, True, cmd, arg,
                                      "ch.room.noself [about] string(question)")
    except: return

    question = question.replace("$", "$$")
    mud.message(ch, tgt, None, None, False, "to_vict",
                "{w$n asks you, '" + question + "'{n")
    mud.message(ch, tgt, None, None, False, "to_char",
                "{wYou ask $N, '" + question + "'{n")

    # run our ask hooks
    hooks.run("ask", hooks.build_info("ch ch str", (ch, tgt, question)))
Exemplo n.º 29
0
def cmd_unlock(ch, cmd, arg):
    '''Usage: unlock <door | direction | container>

       Attempts to unlock the specified door, direction, or container.'''
    try:
        found,type=mud.parse_args(ch,True,cmd,arg, "[the] {obj.room.inv exit }")
    except: return

    # what did we find?
    if type == "exit":
        ex = found
        name = ex.name
        if ex.name == "":
            name = "the exit"
        
        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif not ex.is_locked:
            ch.send(name + " is already unlocked.")
        elif ex.key == '':
            ch.send("You cannot figure out how " + name +
                    " would be unlocked.")
        elif not has_proto(ch, ex.key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You unlock " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n unlocks " + name + ".")
            ex.unlock()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, ex.is_closed, False)

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif not obj.container_is_locked:
            ch.send(ch.see_as(obj) + " is already unlocked.")
        elif obj.container_key == '':
            ch.send("You cannot figure out how to unlock "+ ch.see_as(obj))
        elif not has_proto(ch, obj.container_key):
            ch.send("You cannot seem to find the key.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You unlock $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n unlocks $o.")
            obj.container_is_locked = False
Exemplo n.º 30
0
def try_get_from(ch, cont, arg):
    '''tries to get one item from inside another'''
    if not cont.istype("container"):
        mud.message(ch, None, cont, None, True, "to_char",
                    "$o is not a container.")
    elif cont.container_is_closed:
        mud.message(ch, None, cont, None, True, "to_char", "$o is closed.")
    else:
        # find our count and name
        num, name = utils.get_count(arg)

        # multi or single?
        if num == "all":
            list = utils.find_all_objs(ch, cont.objs, name)
            for obj in list:
                do_get(ch, obj, cont)
        else:
            # obj = find_obj(ch, cont.objs, num, name)
            obj = mudobj.find_obj(arg, cont, ch)
            if obj != None:
                do_get(ch, obj, cont)
            else:
                mud.message(
                    ch, None, cont, None, True, "to_char",
                    "You could not find what you were looking for in $o.")
Exemplo n.º 31
0
def cmd_open(ch, cmd, arg):
    '''Usage: open [the] <direction | door | container>

       Attempts to open the speficied door, direction, or container.'''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg,
                                     "[the] {obj.room.inv exit }")
    except:
        return

    # is it an exit?
    if type == "exit":
        ex = found
        name = ex.name
        if name == "":
            name = "the exit"

        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif ex.is_locked:
            ch.send(name + " must be unlocked first.")
        elif not ex.is_closable:
            ch.send(name + " cannot be opened.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You open " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n opens " + name + ".")
            ex.open()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, False, ex.is_locked)
            hooks.run("open_door", hooks.build_info("ch ex", (ch, ex)))

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif obj.container_is_locked:
            ch.send(ch.see_as(obj) + " must be unlocked first.")
        elif not obj.container_is_closable:
            ch.send(ch.see_as(obj) + " cannot be opened.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You open $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n opens $o.")
            obj.container_is_closed = False
            hooks.run("open_obj", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 32
0
def try_change_pos(ch, pos):
    '''this function attempts to change the position of the person'''
    if ch.pos == pos:
        ch.send("You are already " + pos + ".")
        return False
    else:
        if ch.pos == "flying":
            mud.message(ch,None,None,None,True, "to_char", "You stop flying.")
            mud.message(ch,None,None,None,True, "to_room", "$n stops flying.")

        act = pos_act[positions.index(pos)]
        mud.message(ch, None, None, None, True, "to_char", "You " + act + ".")
        mud.message(ch, None, None, None, True, "to_room", "$n "  + act + "s.")
        ch.pos = pos
        return True
Exemplo n.º 33
0
def do_get(ch, obj, cont):
    '''transfers an item from the ground to the character'''
    if utils.is_keyword(obj.bits, "notake"):
        ch.send("You cannot take " + ch.see_as(obj) + ".")
    elif cont != None:
        obj.carrier = ch
        mud.message(ch, None, obj, cont, True, "to_char", "You get $o from $O.")
        mud.message(ch, None, obj, cont, True, "to_room", "$n gets $o from $O.")
    else:
        obj.carrier = ch
        mud.message(ch, None, obj, None, True, "to_char", "You get $o.")
        mud.message(ch, None, obj, None, True, "to_room", "$n gets $o.")

        # run get hooks
        hooks.run("get", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 34
0
def cmd_goto(ch, cmd, arg):
    '''Usage: goto <person | place | thing>

       Transfer yourself to a specified room, object, or person in game. Rooms
       are referenced by their zone key.
       '''
    try:
        found, type = mud.parse_args(ch, True, cmd, arg, "{ room ch.world.noself }")
    except: return

    # what did we find?
    if type == "char":
        dest = found.room
    else:
        dest = found

    mud.message(ch, None, None, None, True, "to_room",
                "$n disappears in a puff of smoke.")
    ch.room = dest
    ch.act("look")
    mud.message(ch, None, None, None, True, "to_room",
                "$n appears in a puff of smoke.")
    hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
Exemplo n.º 35
0
def cmd_open(ch, cmd, arg):
    '''Usage: open [the] <direction | door | container>

       Attempts to open the speficied door, direction, or container.'''
    try:
        found,type=mud.parse_args(ch,True,cmd,arg, "[the] {obj.room.inv exit }")
    except: return

    # is it an exit?
    if type == "exit":
        ex = found
        name = ex.name
        if name == "":
            name = "the exit"
        
        if not ex.is_closed:
            ch.send(name + " is already open.")
        elif ex.is_locked:
            ch.send(name + " must be unlocked first.")
        elif not ex.is_closable:
            ch.send(name + " cannot be opened.")
        else:
            mud.message(ch, None, None, None, True, "to_char",
                        "You open " + name + ".")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n opens " + name + ".")
            ex.open()
            # hooks.run("room_change", hooks.build_info("rm", (ch.room, )))
            try_manip_other_exit(ch.room, ex, False, ex.is_locked)
            hooks.run("open_door", hooks.build_info("ch ex", (ch, ex)))

    # must be an object
    else:
        obj = found
        if not obj.istype("container"):
            ch.send(ch.see_as(obj) + " is not a container.")
        elif not obj.container_is_closed:
            ch.send(ch.see_as(obj) + " is already open.")
        elif obj.container_is_locked:
            ch.send(ch.see_as(obj) + " must be unlocked first.")
        elif not obj.container_is_closable:
            ch.send(ch.see_as(obj) + " cannot be opened.")
        else:
            mud.message(ch, None, obj, None, True, "to_char", "You open $o.")
            mud.message(ch, None, obj, None, True, "to_room", "$n opens $o.")
            obj.container_is_closed = False
            hooks.run("open_obj", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 36
0
def do_give(ch, recv, obj):
    '''does the handling of the give command'''
    mud.message(ch, recv, obj, None, True, "to_room", "$n gives $o to $N.")
    mud.message(ch, recv, obj, None, True, "to_vict", "$n gives $o to you.")
    mud.message(ch, recv, obj, None, True, "to_char", "You give $o to $N.")
    obj.carrier = recv

    # run our give hook
    hooks.run("give", hooks.build_info("ch ch obj", (ch, recv, obj)))
Exemplo n.º 37
0
def try_change_pos(ch, pos):
    '''this function attempts to change the position of the person'''
    if ch.pos == pos:
        ch.send("You are already " + pos + ".")
        return False
    else:
        if ch.pos == "flying":
            mud.message(ch, None, None, None, True, "to_char",
                        "You stop flying.")
            mud.message(ch, None, None, None, True, "to_room",
                        "$n stops flying.")

        act = pos_act[positions.index(pos)]
        mud.message(ch, None, None, None, True, "to_char", "You " + act + ".")
        mud.message(ch, None, None, None, True, "to_room", "$n " + act + "s.")
        ch.pos = pos
        return True
Exemplo n.º 38
0
def do_get(ch, obj, cont):
    '''transfers an item from the ground to the character'''
    if utils.is_keyword(obj.bits, "notake"):
        ch.send("You cannot take " + ch.see_as(obj) + ".")
    elif cont != None:
        obj.carrier = ch
        mud.message(ch, None, obj, cont, True, "to_char",
                    "You get $o from $O.")
        mud.message(ch, None, obj, cont, True, "to_room",
                    "$n gets $o from $O.")
    else:
        obj.carrier = ch
        mud.message(ch, None, obj, None, True, "to_char", "You get $o.")
        mud.message(ch, None, obj, None, True, "to_room", "$n gets $o.")

        # run get hooks
        hooks.run("get", hooks.build_info("ch obj", (ch, obj)))
Exemplo n.º 39
0
def do_give(ch, recv, obj):
    '''does the handling of the give command'''
    mud.message(ch, recv, obj, None, True, "to_room",
                "$n gives $o to $N.")
    mud.message(ch, recv, obj, None, True, "to_vict",
                "$n gives $o to you.")
    mud.message(ch, recv, obj, None, True, "to_char",
                "You give $o to $N.")
    obj.carrier = recv

    # run our give hook
    hooks.run("give", hooks.build_info("ch ch obj", (ch, recv, obj)))
Exemplo n.º 40
0
def cmd_greet(ch, cmd, arg):
    '''Usage: greet <person>

       NPCs with dialogs will often have something to say when you greet or
       approach then. Greeting an NPC is a way to get them talking.'''
    try:
        tgt, = mud.parse_args(ch, True, cmd, arg, "ch.room.noself")
    except: return

    mud.message(ch, tgt, None, None, False, "to_char", "You greet $N.")
    mud.message(ch, tgt, None, None, False, "to_vict", "$n greets you.")
    mud.message(ch, tgt, None, None, False, "to_room", "$n greets $N.")

    # run greet hooks
    hooks.run("greet",      hooks.build_info("ch ch", (ch, tgt)))
    hooks.run("post_greet", hooks.build_info("ch ch", (ch, tgt)))
Exemplo n.º 41
0
def cmd_greet(ch, cmd, arg):
    '''Usage: greet <person>

       NPCs with dialogs will often have something to say when you greet or
       approach then. Greeting an NPC is a way to get them talking.'''
    try:
        tgt, = mud.parse_args(ch, True, cmd, arg, "ch.room.noself")
    except: return

    mud.message(ch, tgt, None, None, False, "to_char", "You greet $N.")
    mud.message(ch, tgt, None, None, False, "to_vict", "$n greets you.")
    mud.message(ch, tgt, None, None, False, "to_room", "$n greets $N.")

    # run greet hooks
    hooks.run("greet",      hooks.build_info("ch ch", (ch, tgt)))
    hooks.run("post_greet", hooks.build_info("ch ch", (ch, tgt)))
Exemplo n.º 42
0
def try_get_from(ch, cont, arg):
    '''tries to get one item from inside another'''
    if not cont.istype("container"):
        mud.message(ch, None, cont, None, True, "to_char",
                    "$o is not a container.")
    elif cont.container_is_closed:
        mud.message(ch, None, cont, None, True, "to_char", "$o is closed.")
    else:
        # find our count and name
        num, name = utils.get_count(arg)

        # multi or single?
        if num == "all":
            list = utils.find_all_objs(ch, cont.objs, name)
            for obj in list:
                do_get(ch, obj, cont)
        else:
            # obj = find_obj(ch, cont.objs, num, name)
            obj = mudobj.find_obj(arg, cont, ch)
            if obj != None:
                do_get(ch, obj, cont)
            else:
                mud.message(ch, None, cont, None, True, "to_char",
                            "You could not find what you were looking for in $o.")
Exemplo n.º 43
0
def try_move(ch, dir, mssg = False):
    '''Handles all moving of characters from one room to another, through
       commands. Attempts a move. If successful, returns the exit left
       through.'''
    ex      = ch.room.exit(dir)
    success = False

    exname = "it"
    if ex != None and ex.name != "":
        exname = ex.name
    
    # did we find an exit?
    if ex == None or not ch.cansee(ex):
        if not ch.isInGroup("builder"):
            ch.send("Alas, there is no exit in that direction.")
        elif ex != None and not ch.cansee(ex):
            ch.send("There is an exit, but you can't see it.")
            ch.send("Turn on your wizard lense!")
        else:
            hooks.run("try_buildwalk", hooks.build_info("ch str", (ch, dir)))
    elif ex.is_closed:
        ch.send("You will have to open " + exname + " first.")
    elif ex.dest == None:
        ch.send("It doesn't look like " + exname + " leads anywhere!")
    else:
        old_room = ch.room
        dirnum   = dir_index(dir)

        # send out our leave mud.messages as needed. Is anyone in the old room?
        if mssg == True:
            if ex.leave_mssg != '':
                mud.message(ch, None, None, None, True, "to_room",ex.leave_mssg)
            elif dirnum == -1:
                mud.message(ch, None, None, None, True, "to_room", "$n leaves.")
            else:
                mud.message(ch, None, None, None, True, "to_room",
                            "$n leaves " + dir_name[dirnum] + ".")

        # run our leave hooks
        hooks.run("exit", hooks.build_info("ch rm ex", (ch, ch.room, ex)))

        # if a hook hasn't moved us, go through with going through the exit
        if ch.room == old_room:
            ch.room = ex.dest

        # stuff that happens before we 'look'
        hooks.run("pre_enter", hooks.build_info("ch rm", (ch, ch.room)))
            
        ch.act("look")

        # send out our enter mud.messages as needed
        if mssg == True:
            if ex.enter_mssg != '':
                mud.message(ch,None,None,None,True,"to_room",ex.enter_mssg)
            elif dirnum == -1:
                mud.message(ch,None,None,None,True,"to_room","$n has arrived.")
            else:
                mud.message(ch, None, None, None, True, "to_room",
                            "$n arrives from the "+dir_name[dir_opp[dirnum]]+".")

        # run our enter hooks
        hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
        success = True

    # return the exit we found (if we found any)
    return ex, success
Exemplo n.º 44
0
def try_move(ch, dir, mssg=False):
    '''Handles all moving of characters from one room to another, through
       commands. Attempts a move. If successful, returns the exit left
       through.'''
    ex = ch.room.exit(dir)
    success = False

    exname = "it"
    if ex != None and ex.name != "":
        exname = ex.name

    # did we find an exit?
    if ex == None or not ch.cansee(ex):
        ch.send("Alas, there is no exit in that direction.")
    elif ex.is_closed:
        ch.send("You will have to open " + exname + " first.")
    elif ex.dest == None:
        ch.send("It doesn't look like " + exname + " leads anywhere!")
    else:
        old_room = ch.room
        dirnum = dir_index(dir)

        # send out our leave mud.messages as needed. Is anyone in the old room?
        if mssg == True:
            if ex.leave_mssg != '':
                mud.message(ch, None, None, None, True, "to_room",
                            ex.leave_mssg)
            elif dirnum == -1:
                mud.message(ch, None, None, None, True, "to_room",
                            "$n leaves.")
            else:
                mud.message(ch, None, None, None, True, "to_room",
                            "$n leaves " + dir_name[dirnum] + ".")

        # run our leave hooks
        hooks.run("exit", hooks.build_info("ch rm ex", (ch, ch.room, ex)))

        # if a hook hasn't moved us, go through with going through the exit
        if ch.room == old_room:
            ch.room = ex.dest

        # stuff that happens before we 'look'
        hooks.run("pre_enter", hooks.build_info("ch rm", (ch, ch.room)))

        ch.act("look")

        # send out our enter mud.messages as needed
        if mssg == True:
            if ex.enter_mssg != '':
                mud.message(ch, None, None, None, True, "to_room",
                            ex.enter_mssg)
            elif dirnum == -1:
                mud.message(ch, None, None, None, True, "to_room",
                            "$n has arrived.")
            else:
                mud.message(
                    ch, None, None, None, True, "to_room",
                    "$n arrives from the " + dir_name[dir_opp[dirnum]] + ".")

        # run our enter hooks
        hooks.run("enter", hooks.build_info("ch rm", (ch, ch.room)))
        success = True

    # return the exit we found (if we found any)
    return ex, success