def FightEnemy(): enemy = Target.GetTargetFromList('enemy') if enemy != None: Misc.ScriptRun(autoFightMacroName) while enemy != None: Misc.Pause(100) enemy = Mobiles.FindBySerial(enemy.Serial) Player.ChatSay(0, 'left one') Misc.Pause(1000) for i in range(0, 2): Player.ChatSay(0, 'right one') Misc.Pause(1000) corpseFilter = Items.Filter() corpseFilter.Movable = False corpseFilter.RangeMax = 2 corpseFilter.Graphics = List[int]([0x2006]) corpses = Items.ApplyFilter(corpseFilter) corpse = None for corpse in corpses: for item in corpse.Contains: MoveItem(Items, Misc, item, Player.Backpack) fishSteaks = Items.FindByID(0x097A, -1, Player.Backpack.Serial) if fishSteaks != None: MoveItem(Items, Misc, fishSteaks.Serial, corpse.Serial)
def MoveOreToPet(): petSerial = Misc.ReadSharedValue('petForStorage1') if petSerial != None: pet = Mobiles.FindBySerial(Misc.ReadSharedValue('petForStorage1')) if pet == None: Player.HeadMessage(colors['red'], 'Could not find storage pet!') for ore in ores: oreStack = FindItem(ores[ore].itemID, Player.Backpack, ores[ore].color) while oreStack != None: Misc.SendMessage('Moving stack of %s to pet' % ores[ore].name) MoveItem(Items, Misc, oreStack, pet.Backpack) oreStack = Items.FindBySerial(oreStack.Serial) if oreStack != None and oreStack.RootContainer != Player.Serial: # The stack still exists, but was moved to the pet oreStack = None if oreStack == None: continue # Stack wasn't moved, so the pet is either overweight or nearly overweight # Move as much as we can over to the pet by moving one item from the stack at a time amountBeforeMove = FindNumberOfItems(ores[ore].itemID, Player.Backpack, ores[ore].color) MoveItem(Items, Misc, oreStack, pet.Backpack, 1) oreStack = Items.FindBySerial(oreStack.Serial) amountInBag = FindNumberOfItems(ores[ore].itemID, Player.Backpack, ores[ore].color) while amountInBag != amountBeforeMove: amountBeforeMove = amountInBag Misc.SendMessage('%s' % oreStack) MoveItem(Items, Misc, oreStack, pet.Backpack, 1) oreStack = Items.FindBySerial(oreStack.Serial) amountInBag = FindNumberOfItems(ores[ore].itemID, Player.Backpack, ores[ore].color) if Player.Weight <= Player.MaxWeight: Player.HeadMessage( colors['green'], 'Moved enough to pet for you to move normally') Mobiles.Message(pet, colors['red'], 'Pet is overweight!') # There is still some ore in the player's bag return False # We were able to move all of the ore return True
def RestockReagents(): global restockTo global removeReagentsIfOverRestockToAmount reagentsBagSharedValue = 'reagentsBag' if not Misc.CheckSharedValue( reagentsBagSharedValue ): reagentsBag = Target.PromptTarget( 'Select bag to move the reagents into' ) Misc.SetSharedValue( reagentsBagSharedValue, reagentsBag ) reagentsBag = Misc.ReadSharedValue( reagentsBagSharedValue ) if reagentsBag == None or Items.FindBySerial( reagentsBag ) == None: Player.HeadMessage( colors[ 'red' ], 'Can\'t find reagents bag! Clearing stored bag, please run again' ) Misc.RemoveSharedValue( reagentsBagSharedValue ) return reagentsBag = Items.FindBySerial( reagentsBag ) if ( Player.Position.X >= houseTopLeftCornerX and Player.Position.Y >= houseTopLeftCornerY and Player.Position.X <= houseBottomRightCornerX and Player.Position.Y <= houseBottomRightCornerY ): reagentsSource = Items.FindBySerial( houseReagentsChestSerial ) else: reagentsSource = Target.PromptTarget( 'Select container to restock from' ) reagentsSource = Items.FindBySerial( reagentsSource ) if reagentsSource == None or not reagentsSource.IsContainer: Player.HeadMessage( colors[ 'red' ], 'Invalid source container' ) Items.UseItem( reagentsSource ) Misc.Pause( config.dragDelayMilliseconds ) reagentItemIDs = [ reagents[ reagent ].itemID for reagent in reagents ] reagentsInBag = FindNumberOfItems( reagentItemIDs, reagentsBag ) for reagent in reagents: currentReagent = reagents[ reagent ] if reagentsInBag[ currentReagent.itemID ] == restockTo: continue elif reagentsInBag[ currentReagent.itemID ] < restockTo: reagentStackFromReagentsBag = FindItem( currentReagent.itemID, reagentsBag ) reagentStackFromSourceContainer = FindItem( currentReagent.itemID, reagentsSource ) if reagentStackFromReagentsBag == None: MoveItem( Items, Misc, reagentStackFromSourceContainer, reagentsBag, restockTo ) else: MoveItem( Items, Misc, reagentStackFromSourceContainer, reagentsBag, restockTo - reagentStackFromReagentsBag.Amount ) elif removeReagentsIfOverRestockToAmount: reagentStackFromReagentsBag = FindItem( currentReagent.itemID, reagentsBag ) Misc.SendMessage( 'Removing %i %s' % ( reagentStackFromReagentsBag.Amount - restockTo, currentReagent.name ) ) MoveItem( Items, Misc, reagentStackFromReagentsBag, reagentsSource, reagentStackFromReagentsBag.Amount - restockTo )
def MoveReagentsToBag(): for reagent in reagents: reagentItemID = reagents[ reagent ].itemID reagentStack = FindItem( reagentItemID, Player.Backpack, ignoreContainer = [ reagentsBag.Serial ] ) while reagentStack != None: MoveItem( Items, Misc, reagentStack, reagentsBag ) reagentStack = FindItem( reagentItemID, Player.Backpack, ignoreContainer = [ reagentsBag.Serial ] )
from Scripts.utilities.items import MoveItem from Scripts import config sourceBox = Target.PromptTarget('Select container to move items out of') sourceBoxItem = Items.FindBySerial(sourceBox) if sourceBoxItem == None: sourceBox = Mobiles.FindBySerial(sourceBox).Backpack else: sourceBox = sourceBoxItem targetBox = Target.PromptTarget('Select container to move items into') targetBoxItem = Items.FindBySerial(targetBox) if targetBoxItem == None: targetBox = Mobiles.FindBySerial(targetBox).Backpack else: targetBox = targetBoxItem Items.UseItem(sourceBox) Misc.Pause(config.dragDelayMilliseconds) Items.UseItem(targetBox) Misc.Pause(config.dragDelayMilliseconds) for item in sourceBox.Contains: MoveItem(Items, Misc, item, targetBox)
blacksmithingBook = 0x405947BE tailoringBook = 0x4059463F containerWithBODsSerial = Target.PromptTarget('Select container with BODs') if Mobiles.FindBySerial(containerWithBODsSerial) != None: containerWithBODsSerial = Mobiles.FindBySerial( containerWithBODsSerial).Backpack.Serial containerWithBODs = Items.FindBySerial(containerWithBODsSerial) Items.UseItem(containerWithBODs) Misc.Pause(700) from Scripts.utilities.items import FindItem, MoveItem blacksmithingBOD = FindItem(0x14EF, containerWithBODs, 0x044E) while blacksmithingBOD != None: MoveItem(Items, Misc, blacksmithingBOD, blacksmithingBook) blacksmithingBOD = FindItem(0x14EF, containerWithBODs, 0x044E) tailoringBOD = FindItem(0x14EF, containerWithBODs, 0x0483) while tailoringBOD != None: MoveItem(Items, Misc, tailoringBOD, tailoringBook) tailoringBOD = FindItem(0x14EF, containerWithBODs, 0x0483)
if not Timer.Check('Distance'): Player.HeadMessage(msgColor, 'Too Far Away') Timer.Create('Distance', 2500) Items.UseItem(mapChest) Misc.Pause(config.dragDelayMilliseconds) def checkWeight(): if Player.Weight >= Player.MaxWeight: Player.ChatSay(msgColor, 'I am Overweight, stopping') Stop rdaFrag = Items.FindByID(0x0F21, 0x0489, mapChest.Serial) if rdaFrag != None: MoveItem(Items, Misc, rdaFrag, Player.Backpack) if recallHomeScript != None: Misc.ScriptRun(recallHomeScript) Misc.Pause(50) Misc.ScriptStop('resource_treasureChestPuller.py') # Grab the gold for item in mapChest.Contains: checkDistance() checkWeight() if item.ItemID in gold: if beetleBag: if Player.Mount: # Dismount so we can access the beetles bag Mobiles.UseMobile(Player.Serial) Misc.Pause(config.dragDelayMilliseconds)
if not Timer.Check('Distance'): Player.HeadMessage(msgColor, 'Too Far Away') Timer.Create('Distance', 2500) Items.UseItem(mapChest) Misc.Pause(config.dragDelayMilliseconds) def checkWeight(): if Player.Weight >= Player.MaxWeight: Player.ChatSay(msgColor, 'I am Overweight, stopping') Stop rdaFrag = Items.FindByID(0x0F21, 0x0489, mapChest.Serial) if rdaFrag != None: MoveItem(Items, Misc, rdaFrag, Player.Backpack) Misc.SendMessage('RDA FRAG FOUND') Player.ChatGuild('RDA FRAG FOUND') # Move the trash into the trash can for item in mapChest.Contains: checkDistance() checkWeight() if item.ItemID in trashIDs: MoveItem(Items, Misc, item, trashCan) for item in mapChest.Contains: checkDistance() checkWeight() if item.ItemID in scrollIDs: MoveItem(Items, Misc, item, trashCan)
from Scripts.utilities.items import MoveItem item = Player.GetItemOnLayer( 'LeftHand' ) if item != None: MoveItem( Items, Misc, item, Player.Backpack ) item = Player.GetItemOnLayer( 'RightHand' ) if item != None: MoveItem( Items, Misc, item, Player.Backpack )
def TrainCartography(): ''' Trains Cartography to its skill cap ''' if Player.GetRealSkillValue('Cartography') == Player.GetSkillCap( 'Cartography'): Player.HeadMessage(colors['green'], 'Your Cartography is already at its skill cap!') return tool = FindTool(Player.Backpack) if tool == None: Player.HeadMessage(colors['red'], 'No tools to train with!') return trashBarrel = FindTrashBarrel(Items) if trashBarrel == None: Player.HeadMessage( colors['red'], 'No trash barrel nearby! Please move near a trash barrel so that the maps can be thrown away' ) return while not Player.IsGhost and Player.GetRealSkillValue( 'Cartography') < 95.5: # Make sure the tool isn't broken. If it is broken, this will return None tool = Items.FindBySerial(tool.Serial) if tool == None: tool = FindTool(Player.Backpack) if tool == None: Player.HeadMessage(colors['red'], 'Ran out of tools!') return # Select the item to craft itemToCraft = None if Player.GetSkillValue('Cartography') < 50.0: itemToCraft = cartographyCraftables['local map'] elif Player.GetSkillValue('Cartography') < 65.0: itemToCraft = cartographyCraftables['city map'] elif Player.GetSkillValue('Cartography') < 99.5: itemToCraft = cartographyCraftables['world map'] else: Player.HeadMessage( colors['orange'], 'You will need to finish training Cartography by decoding lvl 3 and 4 treasure maps' ) return blankScrolls = FindNumberOfItems(miscellaneous['blank scroll'].itemID, Player.Backpack, 0x0000) if blankScrolls[miscellaneous['blank scroll']. itemID] < itemToCraft.resourcesNeeded['blank scroll']: Player.HeadMessage(colors['red'], 'Out of resources to craft with!') return Items.UseItem(tool) for path in itemToCraft.gumpPath: Gumps.WaitForGump(path.gumpID, 2000) Gumps.SendAction(path.gumpID, path.buttonID) # Wait for crafting to finish and close the gump Gumps.WaitForGump(949095101, 2000) Gumps.SendAction(949095101, 0) map = FindItem(miscellaneous['map'].itemID, Player.Backpack) if map != None: MoveItem(Items, Misc, map, trashBarrel) if not Player.IsGhost: Player.HeadMessage( colors['orange'], 'You will need to finish training Cartography by decoding lvl 3 and 4 treasure maps' )
from Scripts.glossary.spells import spells from Scripts.glossary.items.spellScrolls import spellScrolls spellScrollIDs = [spellScrolls[scroll].itemID for scroll in spellScrolls] from Scripts.utilities.items import MoveItem for item in containerToSort.Contains: if item.ItemID in spellScrollIDs: scrollType = None for scroll in spellScrolls: if spellScrolls[scroll].itemID == item.ItemID: scrollType = spellScrolls[scroll] break spell = spells[scrollType.name.replace(' scroll', '')] if spell.circle == 1: MoveItem(Items, Misc, item, circleOneBag) elif spell.circle == 2: MoveItem(Items, Misc, item, circleTwoBag) elif spell.circle == 3: MoveItem(Items, Misc, item, circleThreeBag) elif spell.circle == 4: MoveItem(Items, Misc, item, circleFourBag) elif spell.circle == 5: MoveItem(Items, Misc, item, circleFiveBag) elif spell.circle == 6: MoveItem(Items, Misc, item, circleSixBag) elif spell.circle == 7: MoveItem(Items, Misc, item, circleSevenBag) elif spell.circle == 8: MoveItem(Items, Misc, item, circleEightBag)
qualities = itemQuality.split('/') allQualitiesMet = True for quality in qualities: if quality not in textInSystem: allQualitiesMet = False if allQualitiesMet: keepItem = True elif Journal.SearchByType(itemQuality, 'System'): keepItem = True if keepItem: break if Journal.SearchByType('Ruin', 'System'): keepItem = False if keepItem: #Misc.SendMessage( 'keep' ) MoveItem(Items, Misc, item, itemsToKeepBox) else: #Misc.SendMessage( 'sell' ) MoveItem(Items, Misc, item, itemsToSellBox) if Journal.SearchByType('This item is out of charges', 'Regular'): Misc.SendMessage('Wand is out of charges! Stopping script', colors['red']) Stop Player.HeadMessage(colors['green'], 'Done identifying the items!')
gemIDs = [gems[gem].itemID for gem in gems] shieldIDs = [ shields[shield].itemID for shield in shields if shields[shield].itemID != 0 ] spellScrollIDs = [spellScrolls[scroll].itemID for scroll in spellScrolls] weaponIDs = [ weapons[weapon].itemID for weapon in weapons if weapons[weapon].itemID != 0 ] #beetle = 0x001D9588 #backpack = Mobiles.FindBySerial( beetle ).Backpack backpack = Player.Backpack gold = FindItem(miscellaneous['gold coin'].itemID, backpack) while gold != None: MoveItem(Items, Misc, gold, goldChest) gold = FindItem(miscellaneous['gold coin'].itemID, backpack) Misc.SendMessage('Emptying weapons', colors['cyan']) weapon = FindItem(weaponIDs, backpack) while weapon != None: Misc.SendMessage(weapon.Name) MoveItem(Items, Misc, weapon, weaponChest) weapon = FindItem(weaponIDs, backpack) Misc.SendMessage('Emptying armor', colors['cyan']) armorPiece = FindItem(armorIDs, backpack) while armorPiece != None: Misc.SendMessage(armorPiece.Name) MoveItem(Items, Misc, armorPiece, armorChest) armorPiece = FindItem(armorIDs, backpack)
nameOfIngotsToDeposit = [ 'dull copper ingot', 'shadow iron ingot', 'copper ingot', 'bronze ingot', 'golden ingot', 'agapite ingot' ] itemsToDeposit = [] for item in miscellaneous: if miscellaneous[item] != None and miscellaneous[ item].name in nameOfItemsToDeposit: itemsToDeposit.append(miscellaneous[item]) for ingot in ingots: if ingots[ingot] != None and ingots[ingot].name in nameOfIngotsToDeposit: itemsToDeposit.append(ingots[ingot]) nameOfItemsFound = [item.name for item in itemsToDeposit] nameOfItemsNotFound = [ itemName for itemName in nameOfItemsToDeposit if not itemName in nameOfItemsFound ] for name in nameOfItemsNotFound: Misc.SendMessage('Unknown item: %s' % name, colors['red']) Player.ChatSay(colors['cyan'], 'bank') Misc.Pause(200) for item in itemsToDeposit: itemInBag = FindItem(item.itemID, Player.Backpack, item.color) if itemInBag != None: MoveItem(Items, Misc, itemInBag, Player.Bank)
def Fish(fishingPole, x, y): ''' Casts the fishing pole and returns True while the fish are biting ''' global fishIDs Journal.Clear() Items.UseItemByID(tools['fishing pole'].itemID) Target.WaitForTarget(2000, True) statics = Statics.GetStaticsTileInfo(x, y, 0) if len(statics) > 0: water = statics[0] Target.TargetExecute(x, y, water.StaticZ, water.StaticID) else: Target.TargetExecute(x, y, -5, 0x0000) Misc.Pause(config.dragDelayMilliseconds) Target.Cancel() Timer.Create('timeout', 20000) while not (Journal.SearchByType( 'You pull', 'Regular' ) or Journal.SearchByType( 'You fish a while, but fail to catch anything.', 'Regular' ) or Journal.SearchByType( 'The fish don\'t seem to be biting here', 'Regular' ) or Journal.SearchByType( 'Your fishing pole bends as you pull a big fish from the depths!', 'Regular') or Journal.SearchByType( 'Uh oh! That doesn' 't look like a fish!', 'Regular')): if not Timer.Check('timeout'): return False Misc.Pause(50) if Journal.SearchByType('The fish don\'t seem to be biting here', 'Regular'): return False if Player.Weight >= Player.MaxWeight: for fishID in fishIDs: fish = Items.FindByID(fishID, -1, Player.Backpack.Serial) if fish != None: Items.UseItemByID(0x0F52) Target.WaitForTarget(2000, True) Target.TargetExecute(fish) Misc.Pause(config.dragDelayMilliseconds) if Player.Weight > Player.MaxWeight - 10: # Drop the trash into the ship's hatch directionsToHatch = [ 'West', 'West', 'North', 'North', 'North', 'North', 'North', 'East', 'East', 'North', 'North', 'North' ] for direction in directionsToHatch: Player.Walk(direction) Misc.Pause(1200) Player.ChatSay(0, 'drop anchor') Misc.Pause(200) hatch = FindHatch(Items) itemIDsToMoveToHatch = [ 0x097A, 0x170F, 0x170D, 0x170B, 0x1711, 0x0DD6, 0x09CC ] for itemID in itemIDsToMoveToHatch: item = Items.FindByID(itemID, -1, Player.Backpack.Serial) while item != None: MoveItem(Items, Misc, item, hatch) item = Items.FindByID(itemID, -1, Player.Backpack.Serial) Player.ChatSay(0, 'raise anchor') Misc.Pause(50) directionsToMast = [ 'South', 'South', 'South', 'East', 'East', 'South', 'South', 'South', 'South', 'South', 'West', 'West' ] for direction in directionsToMast: Player.Walk(direction) Misc.Pause(1200) return True