def CmdGimme(mob,args):
    from item import ItemProto,getTomeAtLevelForScroll
    argUpper = args[0].upper()
    if argUpper == 'TOME':
        itemname = argUpper
        tomename = ' '.join(args[2:-1])    # strip "Tome of" and tome level
    elif argUpper not in ("PLEVEL","SLEVEL","TLEVEL","SKILL","MONEY","XP","RENEW","PRESENCE"):
        itemname = ' '.join(args)
    else:
        itemname = argUpper
        levels = 0
        if len(args) > 1:
            try:
                levels = int(args[1])
            except:
                pass
    
    if itemname == 'MONEY':
        if len(args) > 1:
            try:
                amount = int(args[1])
            except:
                amount = 1000
        else:
            amount = 1000
        mob.player.platinum += amount
        if mob.player.platinum < 0:
            mob.player.platinum = 0
        if amount > 0:
            mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Gained %i platinum.\\n"%amount)
        else:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Lost %i platinum.\\n"%(-amount))
        return
    elif itemname == 'XP':
        for c in mob.player.party.members:
            c.gainXP(1000000)
        return
    elif itemname == 'PLEVEL':
        if levels == 0:
            return #no point in trying
        for x in xrange(0,levels):
            mob.player.curChar.gainLevel(0)
        return
    elif itemname == 'SLEVEL':
        if levels == 0:
            return #no point in trying
        for x in xrange(0,levels):
            mob.player.curChar.gainLevel(1)
        return
    elif itemname == 'TLEVEL':
        if levels == 0:
            return #no point in trying
        for x in xrange(0,levels):
            mob.player.curChar.gainLevel(2)
        return
    elif itemname == 'SKILL':
        if levels == 0:
            return #no point in trying
        m = mob.player.curChar.mob
        for x in xrange(0,levels):
            for skname in m.skillLevels.iterkeys():
                mob.player.curChar.checkSkillRaise(skname,0,0)
        return
    elif itemname == 'PRESENCE':
        if levels < 0:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"The value provided must be a positive integer.\\n")
            return
        if levels > RPG_MAX_PRESENCE:
            levels = RPG_MAX_PRESENCE
            
        currentCharacter = mob.player.curChar 
        currentCharacter.mob.pre = levels
        currentCharacter.mob.preBase = levels
        currentCharacter.spawn.preBase = levels         
        currentCharacter.mob.derivedDirty = True       

        mob.player.sendGameText(RPG_MSG_GAME_GAINED,"You now have %i presence.\\n"%levels)
        return        
    elif itemname == 'RENEW':
        for c in mob.player.party.members:
            m = c.mob
            m.health = m.maxHealth
            m.mana = m.maxMana
            m.stamina = m.maxStamina
        
            m.skillReuse = {}
            m.recastTimers = {}
            
            if m.pet:
                m.pet.health = m.pet.maxHealth
        
        mob.player.cinfoDirty = True
        return
    elif itemname == 'TOME':
        char = mob.player.curChar
        levels = ['1','2','3','4','5','6','7','8','9','10']
        lupper = args[-1].upper()
        try:
            tomelevel = levels.index(lupper) + 1
        except:
            try:
                tomelevel = RPG_ROMAN.index(lupper) + 1
            except:
                mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s isn't a valid tome level!\\n"%args[-1])
                return
        if tomelevel <= 1:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s isn't a valid tome level!\\n"%args[-1])
            return
        try:
            con = ItemProto._connection.getConnection()
            scroll = ItemProto.get(con.execute("SELECT id FROM item_proto WHERE lower(name)=lower(\"Scroll of %s\") LIMIT 1;"%tomename).fetchone()[0])
        except:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s is no spell name!\\n"%tomename)
            return
        nitem = getTomeAtLevelForScroll(scroll,tomelevel)
        if not char.giveItemInstance(nitem):
            nitem.destroySelf()
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s doesn't have enough inventory space\\n"%char.name)
            return
        char.refreshItems()
        mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Gained %s\\n"%nitem.name)
        return
    
    from crafting import FocusGenSpecific
    item = FocusGenSpecific(itemname)
    if item:
        if not mob.player.curChar.giveItemInstance(item):
            item.destroySelf()
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s doesn't have enough inventory space\\n"%char.name)
            return
    else:
        item = mob.player.giveItem(itemname,True,True)
    
    if item:
        if RPG_SLOT_WORN_END > item.slot >= RPG_SLOT_WORN_BEGIN:
            mob.equipItem(item.slot,item)
        mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Gained %s\\n"%item.name)
        return
    
    mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Failure getting %s\\n"%itemname)
Пример #2
0
    def select(self, srcSimObject, tgtSimObject, charIndex, doubleClick, modifier_shift):
        # modifier_shift reserved for mob/character info window
        mob = self.mobLookup[srcSimObject]
        player = mob.player
        if not player:
            traceback.print_stack()
            print "AssertionError: mob is no player mob!"
            return
        mob = player.party.members[charIndex].mob

        if mob.detached:
            player.sendGameText(
                RPG_MSG_GAME_DENIED, r"%s is no longer of this world and cannot interact with it.\n" % mob.name
            )

        target = self.mobLookup[tgtSimObject]

        if modifier_shift:
            player.avatar.sendTgtDesc(mob, target)
            return

        if target.detached and not target.player:
            try:
                if target.kingKiller and target.kingTimer > 0:
                    cmobs = [m.mob for m in target.kingKiller.player.party.members]

                    for a in target.kingKiller.player.alliance.members:
                        for m in a.party.members:
                            cmobs.append(m.mob)

                    if mob not in cmobs:
                        player.sendGameText(RPG_MSG_GAME_LOOT, r"You cannot loot this corpse at this time.\n")
                        return
            except:
                traceback.print_exc()

            # monsters get flesh and blood, bad place for this

            if target.genLoot and target.loot:
                target.genLoot = False
                if not target.loot.generateCorpseLoot():
                    target.loot = None

            if player.realm == RPG_REALM_MONSTER and target.spawn.race not in ("Undead", "Golem"):
                if target.loot and not target.loot.fleshDone and len(target.loot.items) < 16:
                    from item import ItemProto

                    fproto = ItemProto.byName("Flesh and Blood")
                    flesh = fproto.createInstance()
                    flesh.slot = -1
                    target.loot.items.append(flesh)
                    target.loot.fleshDone = True

            # currently the only reason mobs get detached is due to death
            if not target.loot or not len(target.loot.items):
                if target.loot:
                    target.loot.giveMoney(player)
                player.sendGameText(RPG_MSG_GAME_LOOT, r"The corpse crumbles to dust!\n")
                self.removeMob(target)
                return
            if target.master and target.master.player:
                player.sendGameText(RPG_MSG_GAME_LOOT, r"You cannot loot player pets.\n")
                return
            if target.looter and target.looter != mob.player:
                player.sendGameText(
                    RPG_MSG_GAME_LOOT, r"%s is already looting the corpse.\n" % target.looter.curChar.name
                )
                return
            elif target.looter == player:
                return  # no reloot

            # end current looting
            if player.looting:
                player.looting.looter = None
                player.looting = None

            # loot!
            target.looter = player
            player.looting = target
            loot = dict((x, item.itemInfo) for x, item in enumerate(target.loot.items))

            target.loot.giveMoney(player)

            player.mind.callRemote("setLoot", loot)

            return False

        if target.player:
            # find first attached party member
            for c in target.player.party.members:
                if not c.dead:
                    target = c.mob
                    break

        self.setTarget(mob, target, checkVisibility=True)
        if doubleClick:
            # holy cow
            player.avatar.perspective_doCommand("INTERACT", [mob.player.curChar.mob.charIndex])
        # send player mob's id for mouse link
        player.mind.callRemote("mouseSelect", charIndex, target.id)
        return True
Пример #3
0
 def __init__ (self, name, **kwargs):
     ItemProto.__init__ (self, name, **kwargs)
     self.m_parental_deck = None
Пример #4
0
    def select(self, srcSimObject, tgtSimObject, charIndex, doubleClick,
               modifier_shift):
        # modifier_shift reserved for mob/character info window
        mob = self.mobLookup[srcSimObject]
        player = mob.player
        if not player:
            traceback.print_stack()
            print "AssertionError: mob is no player mob!"
            return
        mob = player.party.members[charIndex].mob

        if mob.detached:
            player.sendGameText(
                RPG_MSG_GAME_DENIED,
                r'%s is no longer of this world and cannot interact with it.\n'
                % mob.name)

        target = self.mobLookup[tgtSimObject]

        if modifier_shift:
            player.avatar.sendTgtDesc(mob, target)
            return

        if target.detached and not target.player:
            try:
                if target.kingKiller and target.kingTimer > 0:
                    cmobs = [
                        m.mob for m in target.kingKiller.player.party.members
                    ]

                    for a in target.kingKiller.player.alliance.members:
                        for m in a.party.members:
                            cmobs.append(m.mob)

                    if mob not in cmobs:
                        player.sendGameText(
                            RPG_MSG_GAME_LOOT,
                            r'You cannot loot this corpse at this time.\n')
                        return
            except:
                traceback.print_exc()

            #monsters get flesh and blood, bad place for this

            if target.genLoot and target.loot:
                target.genLoot = False
                if not target.loot.generateCorpseLoot():
                    target.loot = None

            if player.realm == RPG_REALM_MONSTER and \
                target.spawn.race not in ("Undead","Golem"):
                if target.loot and not target.loot.fleshDone and \
                    len(target.loot.items) < 16:
                    from item import ItemProto
                    fproto = ItemProto.byName("Flesh and Blood")
                    flesh = fproto.createInstance()
                    flesh.slot = -1
                    target.loot.items.append(flesh)
                    target.loot.fleshDone = True

            #currently the only reason mobs get detached is due to death
            if not target.loot or not len(target.loot.items):
                if target.loot:
                    target.loot.giveMoney(player)
                player.sendGameText(RPG_MSG_GAME_LOOT,
                                    r'The corpse crumbles to dust!\n')
                self.removeMob(target)
                return
            if target.master and target.master.player:
                player.sendGameText(RPG_MSG_GAME_LOOT,
                                    r'You cannot loot player pets.\n')
                return
            if target.looter and target.looter != mob.player:
                player.sendGameText(
                    RPG_MSG_GAME_LOOT, r'%s is already looting the corpse.\n' %
                    target.looter.curChar.name)
                return
            elif target.looter == player:
                return  #no reloot

            #end current looting
            if player.looting:
                player.looting.looter = None
                player.looting = None

            #loot!
            target.looter = player
            player.looting = target
            loot = dict(
                (x, item.itemInfo) for x, item in enumerate(target.loot.items))

            target.loot.giveMoney(player)

            player.mind.callRemote("setLoot", loot)

            return False

        if target.player:
            #find first attached party member
            for c in target.player.party.members:
                if not c.dead:
                    target = c.mob
                    break

        self.setTarget(mob, target, checkVisibility=True)
        if doubleClick:
            #holy cow
            player.avatar.perspective_doCommand(
                "INTERACT", [mob.player.curChar.mob.charIndex])
        #send player mob's id for mouse link
        player.mind.callRemote("mouseSelect", charIndex, target.id)
        return True
def CmdGimme(mob, args):
    from item import ItemProto, getTomeAtLevelForScroll
    argUpper = args[0].upper()
    if argUpper == 'TOME':
        itemname = argUpper
        tomename = ' '.join(args[2:-1])  # strip "Tome of" and tome level
    elif argUpper not in ("PLEVEL", "SLEVEL", "TLEVEL", "SKILL", "MONEY", "XP",
                          "RENEW", "PRESENCE"):
        itemname = ' '.join(args)
    else:
        itemname = argUpper
        levels = 0
        if len(args) > 1:
            try:
                levels = int(args[1])
            except:
                pass

    if itemname == 'MONEY':
        if len(args) > 1:
            try:
                amount = int(args[1])
            except:
                amount = 1000
        else:
            amount = 1000
        mob.player.platinum += amount
        if mob.player.platinum < 0:
            mob.player.platinum = 0
        if amount > 0:
            mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                                    "Gained %i platinum.\\n" % amount)
        else:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                    "Lost %i platinum.\\n" % (-amount))
        return
    elif itemname == 'XP':
        for c in mob.player.party.members:
            c.gainXP(1000000)
        return
    elif itemname == 'PLEVEL':
        if levels == 0:
            return  #no point in trying
        for x in xrange(0, levels):
            mob.player.curChar.gainLevel(0)
        return
    elif itemname == 'SLEVEL':
        if levels == 0:
            return  #no point in trying
        for x in xrange(0, levels):
            mob.player.curChar.gainLevel(1)
        return
    elif itemname == 'TLEVEL':
        if levels == 0:
            return  #no point in trying
        for x in xrange(0, levels):
            mob.player.curChar.gainLevel(2)
        return
    elif itemname == 'SKILL':
        if levels == 0:
            return  #no point in trying
        m = mob.player.curChar.mob
        for x in xrange(0, levels):
            for skname in m.skillLevels.iterkeys():
                mob.player.curChar.checkSkillRaise(skname, 0, 0)
        return
    elif itemname == 'PRESENCE':
        if levels < 0:
            mob.player.sendGameText(
                RPG_MSG_GAME_DENIED,
                "The value provided must be a positive integer.\\n")
            return
        if levels > RPG_MAX_PRESENCE:
            levels = RPG_MAX_PRESENCE

        currentCharacter = mob.player.curChar
        currentCharacter.mob.pre = levels
        currentCharacter.mob.preBase = levels
        currentCharacter.spawn.preBase = levels
        currentCharacter.mob.derivedDirty = True

        mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                                "You now have %i presence.\\n" % levels)
        return
    elif itemname == 'RENEW':
        for c in mob.player.party.members:
            m = c.mob
            m.health = m.maxHealth
            m.mana = m.maxMana
            m.stamina = m.maxStamina

            m.skillReuse = {}
            m.recastTimers = {}

            if m.pet:
                m.pet.health = m.pet.maxHealth

        mob.player.cinfoDirty = True
        return
    elif itemname == 'TOME':
        char = mob.player.curChar
        levels = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
        lupper = args[-1].upper()
        try:
            tomelevel = levels.index(lupper) + 1
        except:
            try:
                tomelevel = RPG_ROMAN.index(lupper) + 1
            except:
                mob.player.sendGameText(
                    RPG_MSG_GAME_DENIED,
                    "%s isn't a valid tome level!\\n" % args[-1])
                return
        if tomelevel <= 1:
            mob.player.sendGameText(
                RPG_MSG_GAME_DENIED,
                "%s isn't a valid tome level!\\n" % args[-1])
            return
        try:
            con = ItemProto._connection.getConnection()
            scroll = ItemProto.get(
                con.execute(
                    "SELECT id FROM item_proto WHERE lower(name)=lower(\"Scroll of %s\") LIMIT 1;"
                    % tomename).fetchone()[0])
        except:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                    "%s is no spell name!\\n" % tomename)
            return
        nitem = getTomeAtLevelForScroll(scroll, tomelevel)
        if not char.giveItemInstance(nitem):
            nitem.destroySelf()
            mob.player.sendGameText(
                RPG_MSG_GAME_DENIED,
                "%s doesn't have enough inventory space\\n" % char.name)
            return
        char.refreshItems()
        mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                                "Gained %s\\n" % nitem.name)
        return

    from crafting import FocusGenSpecific
    item = FocusGenSpecific(itemname)
    if item:
        if not mob.player.curChar.giveItemInstance(item):
            item.destroySelf()
            mob.player.sendGameText(
                RPG_MSG_GAME_DENIED,
                "%s doesn't have enough inventory space\\n" % char.name)
            return
    else:
        item = mob.player.giveItem(itemname, True, True)

    if item:
        if RPG_SLOT_WORN_END > item.slot >= RPG_SLOT_WORN_BEGIN:
            mob.equipItem(item.slot, item)
        mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                                "Gained %s\\n" % item.name)
        return

    mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                            "Failure getting %s\\n" % itemname)