def Run( self, args ):
     me = BetterMUD.character( self.me )
     string =  "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<#00FF00> Your Inventory\r\n"
     string += "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<$reset> "
     if me.Items() == 0:
         string += "NOTHING!!!\r\n"
     else:
         me.BeginItem()
         while me.IsValidItem():
             item = BetterMUD.item( me.CurrentItem() )
             string += item.Name()
             string += "<#00FF00>, <$reset>"
             me.NextItem()
     string += "\r\n<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<#FFFFFF> Weapon:       <$reset>";
     if me.GetAttribute( "weapon" ) == 0:
         item = BetterMUD.itemtemplate( me.GetAttribute( "defaultweapon" ) )
     else:
         item = BetterMUD.item( me.GetAttribute( "weapon" ) )
     string += item.Name() + "\r\n"
     string += "<#FFFFFF> Total Weight: <$reset>" + str( me.GetAttribute( "encumbrance" ) ) + "\r\n"
     string += "<#FFFFFF> Max Weight:   <$reset>" + str( me.GetAttribute( "maxencumbrance" ) ) + "\r\n"
     string += "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     me.DoAction( "announce", 0, 0, 0, 0, string )
Exemple #2
0
 def Run(self, args):
     me = BetterMUD.character(self.me)
     string = "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<#00FF00> Your Inventory\r\n"
     string += "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<$reset> "
     if me.Items() == 0:
         string += "NOTHING!!!\r\n"
     else:
         me.BeginItem()
         while me.IsValidItem():
             item = BetterMUD.item(me.CurrentItem())
             string += item.Name()
             string += "<#00FF00>, <$reset>"
             me.NextItem()
     string += "\r\n<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     string += "<#FFFFFF> Weapon:       <$reset>"
     if me.GetAttribute("weapon") == 0:
         item = BetterMUD.itemtemplate(me.GetAttribute("defaultweapon"))
     else:
         item = BetterMUD.item(me.GetAttribute("weapon"))
     string += item.Name() + "\r\n"
     string += "<#FFFFFF> Total Weight: <$reset>" + str(
         me.GetAttribute("encumbrance")) + "\r\n"
     string += "<#FFFFFF> Max Weight:   <$reset>" + str(
         me.GetAttribute("maxencumbrance")) + "\r\n"
     string += "<#FFFFFF>--------------------------------------------------------------------------------\r\n"
     me.DoAction("announce", 0, 0, 0, 0, string)
Exemple #3
0
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        me = BetterMUD.character( self.me )
        if action == "query" and data == "canarm":
            item = BetterMUD.item( arg1 )
            if item.GetAttribute( "arms" ) == 1:
                return 1
            return 0

        if action == "do" and data == "arm":
            item = BetterMUD.item( arg3 )
            self.Disarm( 1 )
            self.Arm( item )

        if action == "do" and data == "disarm":
            self.Disarm( arg3 )

        if action == "dropitem" and arg1 == me.ID():
            self.Lose( me, arg2 )

        if action == "giveitem" and arg1 == me.ID():
            self.Lose( me, arg3 )

        if action == "destroyitem":
            self.Lose( me, arg1 )
            
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError
        parms = args.split( None, 1 )
        if len(parms) < 2: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        r = BetterMUD.room( me.Room() )


        recipient = FindTarget( r.SeekCharacter, r.IsValidCharacter, r.CurrentCharacter, parms[0] )
        if recipient == me.ID():
            me.DoAction( "error", 0, 0, 0, 0, "You can't give yourself an object!" )
            return

        quantity = 0
        item = parms[1]

        if string.digits.find( parms[1][0] ) != -1:
            # first letter is a digit, so get quantity
            split = parms[1].split( None, 1 )
            try:
                quantity = int( split[0] )
                item = split[1]
            except:
                # do nothing
                pass

        i = BetterMUD.item( FindTarget( me.SeekItem, me.IsValidItem, me.CurrentItem, item ) )

        # if user didn't specify the quantity of a quantity item,
        # just get the entire amount.
        if i.IsQuantity() and quantity == 0:
            quantity = i.GetQuantity()

        self.mud.DoAction( "attemptgiveitem", me.ID(), r.CurrentCharacter(), me.CurrentItem(), quantity, "" )
Exemple #5
0
 def Disarm( self, itemtype ):
     if itemtype == 1:
         me = BetterMUD.character( self.me )
         if me.GetAttribute( "weapon" ) != 0:
             weapon = BetterMUD.item( me.GetAttribute( "weapon" ) )
             me.SetAttribute( "weapon", 0 )
             self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " disarms " + weapon.Name() + "." )
Exemple #6
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character(self.me)

        quantity = 0
        item = args

        if string.digits.find(args[0]) != -1:
            # first letter is a digit, so get quantity
            split = args.split(None, 1)
            try:
                quantity = int(split[0])
                item = split[1]
            except:
                # do nothing
                pass

        i = BetterMUD.item(
            FindTarget(me.SeekItem, me.IsValidItem, me.CurrentItem, item))

        # if user didn't specify the quantity of a quantity item,
        # just get the entire amount.
        if i.IsQuantity() and quantity == 0:
            quantity = i.GetQuantity()

        self.mud.DoAction("attemptdropitem", me.ID(), me.CurrentItem(),
                          quantity, 0, "")
Exemple #7
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError
        me = BetterMUD.character(self.me)
        r = BetterMUD.room(me.Room())

        quantity = 0
        item = args

        if string.digits.find(args[0]) != -1:
            # first letter is a digit, so get quantity
            split = args.split(None, 1)
            try:
                quantity = int(split[0])
                item = split[1]
            except:
                # do nothing
                pass

        i = BetterMUD.item(
            FindTarget(r.SeekItem, r.IsValidItem, r.CurrentItem, item))
        if i.IsQuantity() and quantity == 0:
            quantity = i.GetQuantity()

        self.mud.DoAction("attemptgetitem", me.ID(), r.CurrentItem(), quantity,
                          0, "")
Exemple #8
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character(self.me)
        r = BetterMUD.room(me.Room())

        time = self.mud.GetTime()
        if time < self.executiontime:
            me.DoAction(
                "error", 0, 0, 0, 0, "You need to wait " + str(
                    (self.executiontime - time) / 1000) +
                " more seconds to use this again!")
            return

        id = FindTarget(r.SeekItem, r.IsValidItem, r.CurrentItem, args)
        item = BetterMUD.item(id)
        name = item.Name()

        # add 120 seconds; 2 minutes
        self.executiontime = time + 120000

        self.mud.AddActionAbsolute(0, "addlogic", 1, id, 0, 0, "uberweight")
        self.mud.AddActionAbsolute(
            0, "vision", r.ID(), 0, 0, 0,
            "<#FF0000>" + me.Name() + " just cast UBERWEIGHT on " + name + "!")
        self.mud.AddActionRelative(20000, "messagelogic", 1, id, 0, 0,
                                   "uberweight remove")
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        r = BetterMUD.room( me.Room() )

        try:
            item = BetterMUD.item( FindTarget( me.SeekItem, me.IsValidItem, me.CurrentItem, args ) )
        except:
            item = BetterMUD.item( FindTarget( r.SeekItem, r.IsValidItem, r.CurrentItem, args ) )

        if not item.DoAction( "query", 0, 0, 0, 0, "canread" ):
            me.DoAction( "error", 0, 0, 0, 0, "Cannot read " + item.Name() + "!" )
            return

        item.DoAction( "do", 0, 0, me.ID(), 0, "read" )
Exemple #10
0
 def Run( self, action, arg1, arg2, arg3, arg4, data ):
     if action == "getitem":
         item = BetterMUD.item( arg2 )
         if item.TemplateID() == 2:
             self.mud.AddActionRelative( 5000, "vision", self.me, 0, 0, 0, "The Baker puts a new pie into the oven!" )
             self.mud.AddActionRelative( 1200000, "spawnitem", 2, self.me, 0, 0, "" )
             self.mud.AddActionRelative( 1200001, "vision", self.me, 0, 0, 0, "A freshly baked Pie pops out of the oven!" )
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )

        quantity = 0
        item = args

        if string.digits.find( args[0] ) != -1:
            # first letter is a digit, so get quantity
            split = args.split( None, 1 )
            try:
                quantity = int( split[0] )
                item = split[1]
            except:
                # do nothing
                pass

        i = BetterMUD.item( FindTarget( me.SeekItem, me.IsValidItem, me.CurrentItem, item ) )

        # if user didn't specify the quantity of a quantity item,
        # just get the entire amount.
        if i.IsQuantity() and quantity == 0:
            quantity = i.GetQuantity()

        self.mud.DoAction( "attemptdropitem", me.ID(), me.CurrentItem(), quantity, 0, "" )
Exemple #12
0
def GiveCurrency( character, recipient, amount ):
    character.BeginItem()
    mud = BetterMUD.GameWrap()
    while character.IsValidItem():
        item = BetterMUD.item( character.CurrentItem() )
        if item.TemplateID() == 1:   # copper pieces
            mud.DoAction( "attemptgiveitem", character.ID(), recipient.ID(), item.ID(), amount, "" )
            return
        character.NextItem()
Exemple #13
0
 def Run(self, action, arg1, arg2, arg3, arg4, data):
     if action == "cangetitem":
         c = BetterMUD.character(arg1)
         me = BetterMUD.item(arg2)
         self.mud.AddActionAbsolute(
             0, "vision", c.Room(), 0, 0, 0,
             c.Name() + " almost has a hernia, trying to pull " +
             me.Name() + " out of the ground!")
         return 1
Exemple #14
0
    def Run(self, action, arg1, arg2, arg3, arg4, data):
        if action == "cangetitem":
            c = BetterMUD.character(arg1)
            me = BetterMUD.item(arg2)
            self.mud.AddActionAbsolute(
                0, "vision", c.Room(), 0, 0, 0,
                c.Name() + " struggles like a madman trying to pull " +
                me.Name() + " off the ground, but it's stuck!")
            return 1

        if action == "messagelogic":
            if data == "uberweight remove":
                self.mud.AddActionAbsolute(0, "dellogic", 1, self.me, 0, 0,
                                           "uberweight")
                me = BetterMUD.item(self.me)
                self.mud.AddActionAbsolute(
                    0, "vision", me.Room(), 0, 0, 0,
                    "The uberweight on " + me.Name() + " wears off!")
Exemple #15
0
 def Disarm(self, itemtype):
     if itemtype == 1:
         me = BetterMUD.character(self.me)
         if me.GetAttribute("weapon") != 0:
             weapon = BetterMUD.item(me.GetAttribute("weapon"))
             me.SetAttribute("weapon", 0)
             self.mud.AddActionAbsolute(
                 0, "vision", me.Room(), 0, 0, 0,
                 me.Name() + " disarms " + weapon.Name() + ".")
Exemple #16
0
 def Run( self, action, arg1, arg2, arg3, arg4, data ):
     if action == "canreceiveitem":
         g = BetterMUD.character( arg1 )
         if not g.IsPlayer(): return 0     # accept stuff from NPC's with the implcit promise that they aren't malicious
         i = BetterMUD.item( arg3 )
         me = BetterMUD.character( self.me )
         me.DoAction( "error", 0, 0, 0, 0, g.Name() + " tried to give you " + i.Name() + " but you have item receiving turned off. Type \"/receive on\" to turn receiving back on." )
         g.DoAction( "error", 0, 0, 0, 0, me.Name() + " refuses to take " + i.Name() + "!" )
         return 1
Exemple #17
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character(self.me)
        r = BetterMUD.room(me.Room())

        try:
            item = BetterMUD.item(
                FindTarget(me.SeekItem, me.IsValidItem, me.CurrentItem, args))
        except:
            item = BetterMUD.item(
                FindTarget(r.SeekItem, r.IsValidItem, r.CurrentItem, args))

        if not item.DoAction("query", 0, 0, 0, 0, "canread"):
            me.DoAction("error", 0, 0, 0, 0,
                        "Cannot read " + item.Name() + "!")
            return

        item.DoAction("do", 0, 0, me.ID(), 0, "read")
Exemple #18
0
def GiveCurrency(character, recipient, amount):
    character.BeginItem()
    mud = BetterMUD.GameWrap()
    while character.IsValidItem():
        item = BetterMUD.item(character.CurrentItem())
        if item.TemplateID() == 1:  # copper pieces
            mud.DoAction("attemptgiveitem", character.ID(), recipient.ID(),
                         item.ID(), amount, "")
            return
        character.NextItem()
Exemple #19
0
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        if action == "getitem":
            item = BetterMUD.item( arg2 )
            print item.TemplateID()
            print "lies"
            if item.TemplateID() == 2:
                print "pies"
                self.mud.AddActionAbsolute( 0, "attemptsay", self.me, 0, 0, 0, "Hey!!!! Thos-a Pies aren't-a FREE!" )
                print "cries"

        return 0
Exemple #20
0
 def Run(self, action, arg1, arg2, arg3, arg4, data):
     if action == "getitem":
         item = BetterMUD.item(arg2)
         if item.TemplateID() == 2:
             self.mud.AddActionRelative(
                 5000, "vision", self.me, 0, 0, 0,
                 "The Baker puts a new pie into the oven!")
             self.mud.AddActionRelative(1200000, "spawnitem", 2, self.me, 0,
                                        0, "")
             self.mud.AddActionRelative(
                 1200001, "vision", self.me, 0, 0, 0,
                 "A freshly baked Pie pops out of the oven!")
Exemple #21
0
    def DoRead( self, character, item, name ):
        c = BetterMUD.character( character )
        i = BetterMUD.item( item )
        if c.HasCommand( name ):
            c.DoAction( "error", 0, 0, 0, 0, "You already know this spell!" )
            return

        c.AddCommand( name )
        self.mud.AddActionAbsolute( 0, "vision", c.Room(), 0, 0, 0, c.Name() + " reads " + i.Name() + "!" )
        self.mud.AddActionAbsolute( 1, "destroyitem", i.ID(), 0, 0, 0, "" )
        c.DoAction( "announce", 0, 0, 0, 0, "You now know the spell " + name + "!" )
        c.DoAction( "announce", 0, 0, 0, 0, "The " + i.Name() + " disappears in a bright flash of flame!" )
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )

        item = BetterMUD.item( FindTarget( me.SeekItem, me.IsValidItem, me.CurrentItem, args ) )

        if not me.DoAction( "query", item.ID(), 0, 0, 0, "canarm" ):
            me.DoAction( "error", 0, 0, 0, 0, "Cannot arm item: " + item.Name() + "!" )
            return

        me.DoAction( "do", 0, 0, item.ID(), 0, "arm" )
Exemple #23
0
def HasEnoughCurrency(character, amount):
    total = 0
    character.BeginItem()
    while character.IsValidItem():
        item = BetterMUD.item(character.CurrentItem())
        if item.TemplateID() == 1:  # copper pieces
            total = total + item.GetQuantity()
        character.NextItem()

    if total >= amount:
        return 1
    return 0
Exemple #24
0
def HasEnoughCurrency( character, amount ):
    total = 0
    character.BeginItem()
    while character.IsValidItem():
        item = BetterMUD.item( character.CurrentItem() )
        if item.TemplateID() == 1:   # copper pieces
            total = total + item.GetQuantity()
        character.NextItem()

    if total >= amount:
        return 1
    return 0
Exemple #25
0
def init():
    mud = BetterMUD.GameWrap()

    # add weight to every item
    mud.BeginItem()
    while mud.IsValidItem():
        item = BetterMUD.item(mud.CurrentItem())
        template = BetterMUD.itemtemplate(item.TemplateID())
        if not item.HasAttribute("weight"):
            item.AddAttribute("weight", template.GetAttribute("weight"))
        mud.NextItem()

    # add encumbrance to every character
    mud.BeginCharacter()
    while mud.IsValidCharacter():
        character = BetterMUD.character(mud.CurrentCharacter())
        template = BetterMUD.charactertemplate(character.TemplateID())
        if not character.HasAttribute("encumbrance"):
            character.AddAttribute("encumbrance",
                                   template.GetAttribute("encumbrance"))
        if not character.HasAttribute("maxencumbrance"):
            character.AddAttribute("maxencumbrance",
                                   template.GetAttribute("maxencumbrance"))

        # now calculate encumbrance of carried items
        character.BeginItem()
        encumbrance = 0
        while character.IsValidItem():
            item = BetterMUD.item(character.CurrentItem())
            if item.IsQuantity():
                encumbrance = encumbrance + item.GetAttribute(
                    "weight") * item.GetQuantity()
            else:
                encumbrance = encumbrance + item.GetAttribute("weight")
            character.NextItem()
        character.SetAttribute("encumbrance", encumbrance)
        if not character.HasLogic("encumbrance"):
            character.AddLogic("encumbrance")
        mud.NextCharacter()
Exemple #26
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character(self.me)

        item = BetterMUD.item(
            FindTarget(me.SeekItem, me.IsValidItem, me.CurrentItem, args))

        if not me.DoAction("query", item.ID(), 0, 0, 0, "canarm"):
            me.DoAction("error", 0, 0, 0, 0,
                        "Cannot arm item: " + item.Name() + "!")
            return

        me.DoAction("do", 0, 0, item.ID(), 0, "arm")
Exemple #27
0
 def Run(self, action, arg1, arg2, arg3, arg4, data):
     if action == "canreceiveitem":
         g = BetterMUD.character(arg1)
         if not g.IsPlayer():
             return 0  # accept stuff from NPC's with the implcit promise that they aren't malicious
         i = BetterMUD.item(arg3)
         me = BetterMUD.character(self.me)
         me.DoAction(
             "error", 0, 0, 0, 0,
             g.Name() + " tried to give you " + i.Name() +
             " but you have item receiving turned off. Type \"/receive on\" to turn receiving back on."
         )
         g.DoAction("error", 0, 0, 0, 0,
                    me.Name() + " refuses to take " + i.Name() + "!")
         return 1
Exemple #28
0
    def Run(self, action, arg1, arg2, arg3, arg4, data):
        me = BetterMUD.character(self.me)
        if action == "query" and data == "canarm":
            item = BetterMUD.item(arg1)
            if item.GetAttribute("arms") == 1:
                return 1
            return 0

        if action == "do" and data == "arm":
            item = BetterMUD.item(arg3)
            self.Disarm(1)
            self.Arm(item)

        if action == "do" and data == "disarm":
            self.Disarm(arg3)

        if action == "dropitem" and arg1 == me.ID():
            self.Lose(me, arg2)

        if action == "giveitem" and arg1 == me.ID():
            self.Lose(me, arg3)

        if action == "destroyitem":
            self.Lose(me, arg1)
def init():
    mud = BetterMUD.GameWrap()

    # add weight to every item
    mud.BeginItem()
    while mud.IsValidItem():
        item = BetterMUD.item( mud.CurrentItem() )
        template = BetterMUD.itemtemplate( item.TemplateID() )
        if not item.HasAttribute( "weight" ):
            item.AddAttribute( "weight", template.GetAttribute( "weight" ) )
        mud.NextItem()

    # add encumbrance to every character
    mud.BeginCharacter()
    while mud.IsValidCharacter():
        character = BetterMUD.character( mud.CurrentCharacter() )
        template = BetterMUD.charactertemplate( character.TemplateID() )
        if not character.HasAttribute( "encumbrance" ):
            character.AddAttribute( "encumbrance", template.GetAttribute( "encumbrance" ) )
        if not character.HasAttribute( "maxencumbrance" ):
            character.AddAttribute( "maxencumbrance", template.GetAttribute( "maxencumbrance" ) )

        # now calculate encumbrance of carried items
        character.BeginItem()
        encumbrance = 0
        while character.IsValidItem():
            item = BetterMUD.item( character.CurrentItem() )
            if item.IsQuantity():
                encumbrance = encumbrance + item.GetAttribute( "weight" ) * item.GetQuantity()
            else:
                encumbrance = encumbrance + item.GetAttribute( "weight" )
            character.NextItem()
        character.SetAttribute( "encumbrance", encumbrance )
        if not character.HasLogic( "encumbrance" ):
            character.AddLogic( "encumbrance" )
        mud.NextCharacter()
Exemple #30
0
    def DoRead(self, character, item, name):
        c = BetterMUD.character(character)
        i = BetterMUD.item(item)
        if c.HasCommand(name):
            c.DoAction("error", 0, 0, 0, 0, "You already know this spell!")
            return

        c.AddCommand(name)
        self.mud.AddActionAbsolute(0, "vision", c.Room(), 0, 0, 0,
                                   c.Name() + " reads " + i.Name() + "!")
        self.mud.AddActionAbsolute(1, "destroyitem", i.ID(), 0, 0, 0, "")
        c.DoAction("announce", 0, 0, 0, 0,
                   "You now know the spell " + name + "!")
        c.DoAction(
            "announce", 0, 0, 0, 0,
            "The " + i.Name() + " disappears in a bright flash of flame!")
Exemple #31
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character(self.me)
        me.SeekItem(args)

        if me.IsValidItem():
            item = me.CurrentItem()
        else:
            room = BetterMUD.room(me.Room())
            room.SeekItem(args)
            if room.IsValidItem():
                item = room.CurrentItem()
            else:
                me.DoAction("error", 0, 0, 0, 0, "Cannot find item: " + args)
                return

        i = BetterMUD.item(item)
        me.DoAction("announce", 0, 0, 0, 0, "Destroying Item: " + i.Name())
        self.mud.AddActionAbsolute(0, "destroyitem", item, 0, 0, 0, "")
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        me.SeekItem( args )

        if me.IsValidItem():
            item = me.CurrentItem()
        else:
            room = BetterMUD.room( me.Room() )
            room.SeekItem( args )
            if room.IsValidItem():
                item = room.CurrentItem()
            else:
                me.DoAction( "error", 0, 0, 0, 0, "Cannot find item: " + args )
                return

        i = BetterMUD.item( item )
        me.DoAction( "announce", 0, 0, 0, 0, "Destroying Item: " + i.Name() )
        self.mud.AddActionAbsolute( 0, "destroyitem", item, 0, 0, 0, "" )
Exemple #33
0
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        r = BetterMUD.room( me.Room() )

        time = self.mud.GetTime()
        if time < self.executiontime:
            me.DoAction( "error", 0, 0, 0, 0, "You need to wait " + str( (self.executiontime - time) / 1000 ) + " more seconds to use this again!" )
            return

        id = FindTarget( r.SeekItem, r.IsValidItem, r.CurrentItem, args )
        item = BetterMUD.item( id )
        name = item.Name()

        # add 120 seconds; 2 minutes
        self.executiontime = time + 120000

        self.mud.AddActionAbsolute( 0, "addlogic", 1, id, 0, 0, "uberweight" )
        self.mud.AddActionAbsolute( 0, "vision", r.ID(), 0, 0, 0, "<#FF0000>" + me.Name() + " just cast UBERWEIGHT on " + name + "!" )
        self.mud.AddActionRelative( 20000, "messagelogic", 1, id, 0, 0, "uberweight remove" )
def init():
    mud = BetterMUD.GameWrap()

    # add arms to every item
    mud.BeginItem()
    while mud.IsValidItem():
        item = BetterMUD.item( mud.CurrentItem() )
        template = BetterMUD.itemtemplate( item.TemplateID() )
        if not item.HasAttribute( "arms" ):
            item.AddAttribute( "arms", template.GetAttribute( "arms" ) )
        mud.NextItem()

    # add defaultweapon and weapon to every character
    mud.BeginCharacter()
    while mud.IsValidCharacter():
        character = BetterMUD.character( mud.CurrentCharacter() )
        template = BetterMUD.charactertemplate( character.TemplateID() )
        if not character.HasAttribute( "defaultweapon" ):
            character.AddAttribute( "defaultweapon", template.GetAttribute( "defaultweapon" ) )
        if not character.HasAttribute( "weapon" ):
            character.AddAttribute( "weapon", template.GetAttribute( "weapon" ) )
        mud.NextCharacter()
Exemple #35
0
    def Run(self, args):
        if not args: raise PythonCommand.UsageError
        parms = args.split(None, 1)
        if len(parms) < 2: raise PythonCommand.UsageError

        me = BetterMUD.character(self.me)
        r = BetterMUD.room(me.Room())

        recipient = FindTarget(r.SeekCharacter, r.IsValidCharacter,
                               r.CurrentCharacter, parms[0])
        if recipient == me.ID():
            me.DoAction("error", 0, 0, 0, 0,
                        "You can't give yourself an object!")
            return

        quantity = 0
        item = parms[1]

        if string.digits.find(parms[1][0]) != -1:
            # first letter is a digit, so get quantity
            split = parms[1].split(None, 1)
            try:
                quantity = int(split[0])
                item = split[1]
            except:
                # do nothing
                pass

        i = BetterMUD.item(
            FindTarget(me.SeekItem, me.IsValidItem, me.CurrentItem, item))

        # if user didn't specify the quantity of a quantity item,
        # just get the entire amount.
        if i.IsQuantity() and quantity == 0:
            quantity = i.GetQuantity()

        self.mud.DoAction("attemptgiveitem", me.ID(), r.CurrentCharacter(),
                          me.CurrentItem(), quantity, "")
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError
        me = BetterMUD.character( self.me )
        r = BetterMUD.room( me.Room() )

        quantity = 0
        item = args

        if string.digits.find( args[0] ) != -1:
            # first letter is a digit, so get quantity
            split = args.split( None, 1 )
            try:
                quantity = int( split[0] )
                item = split[1]
            except:
                # do nothing
                pass

        i = BetterMUD.item( FindTarget( r.SeekItem, r.IsValidItem, r.CurrentItem, item ) )
        if i.IsQuantity() and quantity == 0:
            quantity = i.GetQuantity()

        self.mud.DoAction( "attemptgetitem", me.ID(), r.CurrentItem(), quantity, 0, "" )
Exemple #37
0
def init():
    mud = BetterMUD.GameWrap()

    # add arms to every item
    mud.BeginItem()
    while mud.IsValidItem():
        item = BetterMUD.item(mud.CurrentItem())
        template = BetterMUD.itemtemplate(item.TemplateID())
        if not item.HasAttribute("arms"):
            item.AddAttribute("arms", template.GetAttribute("arms"))
        mud.NextItem()

    # add defaultweapon and weapon to every character
    mud.BeginCharacter()
    while mud.IsValidCharacter():
        character = BetterMUD.character(mud.CurrentCharacter())
        template = BetterMUD.charactertemplate(character.TemplateID())
        if not character.HasAttribute("defaultweapon"):
            character.AddAttribute("defaultweapon",
                                   template.GetAttribute("defaultweapon"))
        if not character.HasAttribute("weapon"):
            character.AddAttribute("weapon", template.GetAttribute("weapon"))
        mud.NextCharacter()
Exemple #38
0
 def Weight(self, i, q):
     item = BetterMUD.item(i)
     if item.IsQuantity():
         return q * item.GetAttribute("weight")
     else:
         return item.GetAttribute("weight")
Exemple #39
0
 def Weight( self, i, q ):
     item = BetterMUD.item( i )
     if item.IsQuantity():
         return q * item.GetAttribute( "weight" )
     else:
         return item.GetAttribute( "weight" )
Exemple #40
0
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        me = BetterMUD.character( self.me )


        if action == "modifyattribute" and data == "experience":
            me.DoAction( "announce", 0, 0, 0, 0, "<#00FFFF>You gain " + str( arg4 ) + " experience!" )
            return

        # check for death
        if action == "modifyattribute" and data == "hitpoints":
            if arg3 <= 0:
                me.DoAction( "do", 0, 0, 0, 0, "died" )
            return

        # you killed someone... celebrate!
        if action == "do" and data == "killed":
            self.Break( me )
            return

        if action == "do" and data == "died":
            self.Break( me )
            self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " dies!!!" )

            # calculate how much experience to give to everyone attacking you
            experience = me.GetAttribute( "giveexperience" )
            if len( self.attackedlist ) > 0:
                experience = experience / len( self.attackedlist )

            # go through everyone, tell them you died, and give them their experience

            for x in self.attackedlist[:]:
                c = BetterMUD.character( x )
                c.DoAction( "do", 0, 0, self.me, 0, "killed" )
                self.mud.DoAction( "modifyattribute", 0, x, c.GetAttribute( "experience" ) + experience, experience, "experience" )

            # clear the list
            self.attackedlist = []

            # go through all his items and force them to drop
            me.BeginItem()
            while me.IsValidItem():
                self.mud.DoAction( "dropitem", me.ID(), me.CurrentItem(), 0, 0, "" )
                me.NextItem()

            # now figure out how to kill the character
            if not me.IsPlayer():
                # just destroy non-players
                self.mud.AddActionAbsolute( 0, "destroycharacter", self.me, 0, 0, 0, "" )
            else:
                # give the player some hitpoints back
                me.SetAttribute( "hitpoints", (me.GetAttribute( "maxhitpoints" ) / 10) * 7 )

                # now spawn the player somewhere, checking the current room, current region, current character,
                # and finally giving up and sending the player to room 1.
                r = BetterMUD.room( me.Room() )
                if r.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                r = BetterMUD.region( me.Region() )
                if r.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                if me.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                self.mud.DoAction( "forcetransport", me.ID(), 1, 0, 0, "" )
            return


        # reset hp if maxhp goes down below hp.
        if action == "modifyattribute" and data == "maxhitpoints":
            if me.GetAttribute( "hitpoints" ) > me.GetAttribute( "maxhitpoints" ):
                me.SetAttribute( "hitpoints", me.GetAttribute( "maxhitpoints" ) )
            return

        # people with the combat module can be attacked
        if action == "query" and data == "canattack":
            return 1


        # add character to attacked list if he isn't there
        if action == "do" and data == "attacked":
            try:
                self.attackedlist.index( arg3 )
            except:
                self.attackedlist.append( arg3 )
            return

        # remove character from attacked list
        if action == "do" and data == "brokeattack":
            try:
                self.attackedlist.remove( arg3 )
            except:
                pass
            return


        # initiate an attack
        if action == "do" and data == "initattack":
            if arg3 == self.me: return

            # clear the old target if attacking someone else
            if self.target != 0:
                t = BetterMUD.character( self.target )
                t.DoAction( "do", 0, 0, self.me, 0, "brokeattack" )
            else:
                self.mud.AddActionRelative( 0, "do", 0, self.me, 0, 0, "attack" )

            # set the new target and tell him he's been attacked
            self.target = arg3
            t = BetterMUD.character( arg3 )
            t.DoAction( "do", 0, 0, self.me, 0, "attacked" )
            self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " begins attacking " + t.Name() + "!!" )
            return


        # clear the old target if attacking someone else
        if action == "do" and data == "breakattack":
            self.Break( me )
            return

        # break if target or you leaves room
        if action == "leaveroom":
            if arg1 == self.target or arg1 == self.me:
                self.Break( me )
            return

        if action == "do" and data == "attack":

            # get the target
            target = BetterMUD.character( self.target )

            # set another attack round
            self.mud.AddActionRelative( self.attacktime, "do", 0, self.me, 0, 0, "attack" )

            # get the weapon
            if me.GetAttribute( "weapon" ) == 0:
                weapon = BetterMUD.itemtemplate( me.GetAttribute( "defaultweapon" ) )
            else:
                weapon = BetterMUD.item( me.GetAttribute( "weapon" ) )

            # calculate the accuracy
            accuracy = weapon.GetAttribute( "accuracy" )
            accuracy += target.DoAction( "query", me.ID(), target.ID(), 0, 0, "getaccuracydelta" )
            accuracy += me.DoAction( "query", me.ID(), target.ID(), 0, 0, "getaccuracydelta" )

            # see if you hit him
            if accuracy <= random.randint( 0, 99 ):
                self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " swings at " + target.Name() + " with " + weapon.Name() + ", but misses!" )
                return

            # calculate damage and hit
            damage = random.randint( weapon.GetAttribute( "mindamage" ), weapon.GetAttribute( "maxdamage" ) )
            self.mud.DoAction( "vision", me.Room(), 0, 0, 0, "<#FF0000>" + me.Name() + " hits " + target.Name() + " with " + weapon.Name() + " for " + str( damage ) + " damage!" )
            self.mud.DoAction( "modifyattribute", 0, target.ID(), target.GetAttribute( "hitpoints" ) - damage, damage, "hitpoints" )
Exemple #41
0
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        me = BetterMUD.character( self.me )

        if action == "canleaveroom":
            if me.GetAttribute( "encumbrance" ) > me.GetAttribute( "maxencumbrance" ):
                me.DoAction( "error", 0, 0, 0, 0, "You cannot move! You're too heavy! Drop something first!" )
                return 1
            return 0

        if action == "getitem":
            if arg1 == self.me:
                item = BetterMUD.item( arg2 )
                weight = self.Weight( arg2, arg3 )
                me.SetAttribute( "encumbrance", me.GetAttribute( "encumbrance" ) + weight )
            return 0

        if action == "dropitem":
            if arg1 == self.me:
                item = BetterMUD.item( arg2 )
                weight = self.Weight( arg2, arg3 )
                me.SetAttribute( "encumbrance", me.GetAttribute( "encumbrance" ) - weight )
            return 0

        if action == "destroyitem":
            item = BetterMUD.item( arg1 )
            weight = self.Weight( arg1, item.GetQuantity() )
            me.SetAttribute( "encumbrance", me.GetAttribute( "encumbrance" ) - weight )
            return 0

        if action == "giveitem":
            if arg1 == self.me:
                item = BetterMUD.item( arg3 )
                weight = self.Weight( arg3, arg4 )
                me.SetAttribute( "encumbrance", me.GetAttribute( "encumbrance" ) - weight )
            if arg2 == self.me:
                item = BetterMUD.item( arg3 )
                weight = self.Weight( arg3, arg4 )
                me.SetAttribute( "encumbrance", me.GetAttribute( "encumbrance" ) + weight )
            return 0

        if action == "spawnitem":
            item = BetterMUD.item( arg1 )
            weight = self.Weight( arg1, item.GetQuantity() )
            me.SetAttribute( "encumbrance", me.GetAttribute( "encumbrance" ) + weight )
            return 0

        if action == "cangetitem":
            item = BetterMUD.item( arg2 )
            weight = self.Weight( arg2, arg3 )
            if weight + me.GetAttribute( "encumbrance" ) > me.GetAttribute( "maxencumbrance" ):
                me.DoAction( "error", 0, 0, 0, 0, "You can't pick up " + item.Name() + " because it's too heavy for you to carry!" )
                return 1
            return 0

        if action == "canreceiveitem":
            g = BetterMUD.character( arg1 )
            item = BetterMUD.item( arg3 )
            weight = self.Weight( arg3, arg4 )
            if weight + me.GetAttribute( "encumbrance" ) > me.GetAttribute( "maxencumbrance" ):
                me.DoAction( "error", 0, 0, 0, 0, g.Name() + " tried to give you " + item.Name() + " but it's too heavy for you to carry!" )
                g.DoAction( "error", 0, 0, 0, 0, "You can't give " + me.Name() + " the " + item.Name() + " because it is too heavy!" )
                return 1
            return 0
Exemple #42
0
    def Run(self, action, arg1, arg2, arg3, arg4, data):
        me = BetterMUD.character(self.me)

        if action == "canleaveroom":
            if me.GetAttribute("encumbrance") > me.GetAttribute(
                    "maxencumbrance"):
                me.DoAction(
                    "error", 0, 0, 0, 0,
                    "You cannot move! You're too heavy! Drop something first!")
                return 1
            return 0

        if action == "getitem":
            if arg1 == self.me:
                item = BetterMUD.item(arg2)
                weight = self.Weight(arg2, arg3)
                me.SetAttribute("encumbrance",
                                me.GetAttribute("encumbrance") + weight)
            return 0

        if action == "dropitem":
            if arg1 == self.me:
                item = BetterMUD.item(arg2)
                weight = self.Weight(arg2, arg3)
                me.SetAttribute("encumbrance",
                                me.GetAttribute("encumbrance") - weight)
            return 0

        if action == "destroyitem":
            item = BetterMUD.item(arg1)
            weight = self.Weight(arg1, item.GetQuantity())
            me.SetAttribute("encumbrance",
                            me.GetAttribute("encumbrance") - weight)
            return 0

        if action == "giveitem":
            if arg1 == self.me:
                item = BetterMUD.item(arg3)
                weight = self.Weight(arg3, arg4)
                me.SetAttribute("encumbrance",
                                me.GetAttribute("encumbrance") - weight)
            if arg2 == self.me:
                item = BetterMUD.item(arg3)
                weight = self.Weight(arg3, arg4)
                me.SetAttribute("encumbrance",
                                me.GetAttribute("encumbrance") + weight)
            return 0

        if action == "spawnitem":
            item = BetterMUD.item(arg1)
            weight = self.Weight(arg1, item.GetQuantity())
            me.SetAttribute("encumbrance",
                            me.GetAttribute("encumbrance") + weight)
            return 0

        if action == "cangetitem":
            item = BetterMUD.item(arg2)
            weight = self.Weight(arg2, arg3)
            if weight + me.GetAttribute("encumbrance") > me.GetAttribute(
                    "maxencumbrance"):
                me.DoAction(
                    "error", 0, 0, 0, 0, "You can't pick up " + item.Name() +
                    " because it's too heavy for you to carry!")
                return 1
            return 0

        if action == "canreceiveitem":
            g = BetterMUD.character(arg1)
            item = BetterMUD.item(arg3)
            weight = self.Weight(arg3, arg4)
            if weight + me.GetAttribute("encumbrance") > me.GetAttribute(
                    "maxencumbrance"):
                me.DoAction(
                    "error", 0, 0, 0, 0,
                    g.Name() + " tried to give you " + item.Name() +
                    " but it's too heavy for you to carry!")
                g.DoAction(
                    "error", 0, 0, 0, 0, "You can't give " + me.Name() +
                    " the " + item.Name() + " because it is too heavy!")
                return 1
            return 0