Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#=============================================================================== # ■ Klein's Secret Bases script for Essentials # Version 1 (4/5/15) # - http://kleinstudio.deviantart.com # Be sure to give credits if you're using this. # - How to use # * Creating the secret base map # - Map needs to be named how you've configured it in SECRETBASEMAPNAME # **IMPORTANT** By defaut you need to name them "Secret Base". # - Event for PC needs to be called BASEPC. **IMPORTANT** # * For info about the BASEPC eventn check the events in the demo. # - If you make holes, they need to be in layer 2. # # * Creating the entrance for a secret base # - Event for entrance needs to be called SECRETBASE+Secret base map ID. # * For example, if this entrance goes to secret base with map id 32, # the event needs to be called SECRETBASE32 # * For info about SECRETBASE event, check the events in the demo. # # ■ Edited and expanded by Ulithium_Dragon. # #=============================================================================== # ■ General settings #=============================================================================== # Map id where items events are allocated ITEMSMAP=108 # Secret Bases tileset name SECRETBASETILESET="bases" # Name for secret bases maps SECRETBASEMAPNAME="Secret Base" # Allow to place dolls and cushions everywhere DOLLSEVERYWHERE=true # Terrain tag for ground decorations that already are in # the base, for example rocks or bushes in layer 1 # If your ground decoration is in layer 2 or 3, then don't worry # about this GROUNDDECORATION=20 # Terrain tag for walls # You can post posters on every tile with this terrain tag WALLTERRAINTAG=21 # Terrain tag for special items that can be used # for placing dolls. ITEMFORDOLL=22 # Move needed for make secret bases BASEMOVENEEDED=:SECRETPOWER #=============================================================================== # ■ Secret Base Bag pockets # [Pocket name, max items] #=============================================================================== BASEBAGPOCKETS=[ ["Desk",100], ["Chair",100], ["Plant",100], ["Ornament",300], ["Mat",300], ["Poster",100], ["Doll",400], ["Cushion",100], ] #=============================================================================== # Type of items #=============================================================================== module ItemType DESK=0 CHAIR=1 PLANT=2 ORNAMENT=3 MAT=4 POSTER=5 DOLL=6 CUSHION=7 end #=============================================================================== # ■ Items are stored here # To add a new item place this in the last position (* New Items) # ["name", tileid, width, height, prize, event, type, board, "description"], # # -Explanation # * Name - Item name # * Tileid - Item Tile ID **************READ***************** # Imagine this is a tileset, Tile ID's are like this # [00][01][02][03][04][05][06][07] # [08][09][10][11][12][13][14][15] # [16][17][18][19][20][21][22][23]... # # The Tile ID placed here has to be the top-left Tile ID of the item- # **********FAST USER FUNCTION********** # You can use pbMakeNumericTileset(TILESETNAME) to create a new .png # in the game's folder with a tileset and a numeric patron. # # * Witdh # - Width in tiles (1, 2...) # *If the item is an event item, leave this at 1 # * Height # - Height in tiles (1, 2...) # *If the item is an event item, leave this at 1 # * Price - Price when shopping # * Event - Event ID # If you don't want your item to be an event, just place 'nil' here # * Creating Interactable Items **************READ***************** # If you want your item to be interactable, create a new event in the # ITEMSMAP and write the Event Id here. Interactable items are not tiles # so you need to select a graphic in the event if you don't want it to be # invisible. # # * Type - Type of item (ItemType::POSTER, ItemType::DESK...) # Some types has specials features: # *POSTER - This item only can be placed on a WALLTERRAINTAG tile. # Also *CUSHION and *DOLL can only be placed on items marked as table if # you don't enable DOLLSEVERYWHERE. Dolls and cushions ALWAYS needs to be # Events items. # # * Board # - This kind of item can be placed on top of holes # *If you don't want the tile to be used like this, just place 'false' # # * Description - Item description (A small chair...) # #=============================================================================== # ■ Items #=============================================================================== SECRETBASEITEMS=[ [-1], #* Desks ["Brick Desk",336,3,3,2000,nil,ItemType::DESK,false,"A huge desk made of bricks. Holds lot of decorations."], ["Camp Desk",360,3,3,2000,nil,ItemType::DESK,false,"A huge desk made of logs. Holds lot of decorations."], ["Comfort Desk",355,3,2,2000,nil,ItemType::DESK,false,"A large desk made of leaves. Put some decorations on it."], ["Hard Desk",384,3,3,2000,nil,ItemType::DESK,false,"A huge desk made of rock. Holds lot of decorations."], ["Heavy Desk",371,3,2,2000,nil,ItemType::DESK,false,"A large desk made of steel. Put some decorations on it."], ["Pokémon Desk",339,1,1,1000,nil,ItemType::DESK,false,"A small desk built in the shape of a Poké Ball."], ["Pretty Desk",408,3,3,2000,nil,ItemType::DESK,false,"A huge desk made of glass. Holds lot of decorations."], ["Ragged Desk",387,3,2,2000,nil,ItemType::DESK,false,"A large desk made of wood. Put some decorations on it."], ["Small Desk",340,1,1,1000,nil,ItemType::DESK,false,"A small desk made for one."], #* Chairs ["Brick Chair",314,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of brick."], ["Camp Chair",315,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of logs."], ["Comfort Chair",316,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of leaves."], ["Hard Chair",322,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of rock."], ["Heavy Chair",323,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of steel."], ["Pokémon Chair",324,1,1,1000,nil,ItemType::CHAIR,false,"A small chair built in the shape of a Poké Ball."], ["Pretty Chair",330,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of glass."], ["Ragged Chair",331,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made of wood."], ["Small Chair",332,1,1,1000,nil,ItemType::CHAIR,false,"A small chair made for one."], #* Plants ["Big Plant",309,2,2,2000,nil,ItemType::PLANT,false,"A large, umbrella-shaped plant in a big pot."], ["Colorful Flowers",325,2,2,2000,nil,ItemType::PLANT,false,"A large pot with many colorful flowers."], ["Gorgeous Plant",341,2,2,2000,nil,ItemType::PLANT,false,"A large impressive plant in a big pot."], ["Red Plant",311,1,2,1000,nil,ItemType::PLANT,false,"A vivid red potted plant."], ["Tropical Plant",327,1,2,1000,nil,ItemType::PLANT,false,"A flowering tropical plant in a pot."], ["Pretty Flower",343,1,2,1000,nil,ItemType::PLANT,false,"A pot of cute flowes."], #* Ornaments ["Red Balloon",136,1,1,500,4,ItemType::ORNAMENT,false,"A red balloon filled with water. Bursts if stepped on."], ["Red Tent",129,3,3,5000,nil,ItemType::ORNAMENT,false,"A red tent to hide in."], ["Blue Tent",132,3,3,5000,nil,ItemType::ORNAMENT,false,"A blue tent to hide in."], ["Sand Ornament",160,1,1,1200,7,ItemType::ORNAMENT,false,"A sand sculpture that crumbles when touched."], ["Slide",304,2,4,5000,nil,ItemType::ORNAMENT,false,"A blue slide."], ["Long Board",6,1,2,1000,nil,ItemType::ORNAMENT,true,"A board used to cover holes."], ["Wide Board",30,2,1,1000,nil,ItemType::ORNAMENT,true,"A board used to cover holes."], ["Big Board",54,2,2,1500,nil,ItemType::ORNAMENT,true,"A board used to cover holes."], #* Mats ["Surf Mat",218,3,3,900,nil,ItemType::MAT,false,"A mat designed with a Surf image. Put items on top."], ["Fire Blast Mat",242,3,3,900,nil,ItemType::MAT,false,"A mat designed with a Fire Blast image. Put items on top."], ["Attract Mat",266,3,3,900,nil,ItemType::MAT,false,"A mat designed with an Attract image. Put items on top."], ["Spikes Mat",290,3,3,900,nil,ItemType::MAT,false,"A mat designed with a Spikes image. Put items on top."], ["Thunder Mat",237,3,3,900,nil,ItemType::MAT,false,"A mat designed with a Thunder image. Put items on top."], ["Powder Snow Mat",261,3,3,900,nil,ItemType::MAT,false,"A mat designed with a Powder Snow image. Put items on top."], ["Fissure Mat",285,3,3,900,nil,ItemType::MAT,false,"A mat designed with a Fissure image. Put items on top."], ["Jump mat",128,1,1,500,ItemType::MAT,false,"A trick mat that jumps when it is stepped on."], #* Posters ["Ball Poster",358,1,1,1000,nil,ItemType::POSTER,false,"A small poster printed with a Poké Ball."], ["Green Poster",359,1,1,1000,nil,ItemType::POSTER,false,"A small poster with a Treecko print."], ["Red Poster",366,1,1,1000,nil,ItemType::POSTER,false,"A small poster with a Torchic print."], ["Blue Poster",367,1,1,1000,nil,ItemType::POSTER,false,"A small poster with a Mudkip print."], ["Cute Poster",374,1,1,1000,nil,ItemType::POSTER,false,"A small poster with a Azurill print."], ["Pika Poster",382,2,1,1500,nil,ItemType::POSTER,false,"A large poster with a Pikachu and Pichu print."], ["Long Poster",390,2,1,1500,nil,ItemType::POSTER,false,"A large poster with a Seviper print."], ["Sea Poster",398,2,1,1500,nil,ItemType::POSTER,false,"A large poster with a Relicanth print."], ["Sky Poster",406,2,1,1500,nil,ItemType::POSTER,false,"A large poster with a Wingull print."], ["Kiss Poster",414,2,1,1500,nil,ItemType::POSTER,false,"A large poster with a Smoochum print."], #* Dolls #Large ["Lapras Doll",200,1,1,5000,2,ItemType::DOLL,false,"A Lapras doll. Place it on a mat or a desk."], ["Regirock Doll",208,1,1,5000,22,ItemType::DOLL,false,"A Regirock doll. Place it on a mat or a desk."], ["Regice Doll",216,1,1,5000,23,ItemType::DOLL,false,"A Regice doll. Place it on a mat or a desk."], ["Registeel Doll",224,1,1,5000,24,ItemType::DOLL,false,"A Registeel doll. Place it on a mat or a desk."], ["Wailmer Doll",233,1,1,5000,25,ItemType::DOLL,false,"A Wailmer doll. Place it on a mat or a desk."], #Small ["Torchic Doll",201,1,1,1000,3,ItemType::DOLL,false,"A Torchic doll. Place it on a mat or a desk."], ["Treecko Doll",209,1,1,1000,5,ItemType::DOLL,false,"A Treecko doll. Place it on a mat or a desk."], ["Mudkip Doll",217,1,1,1000,6,ItemType::DOLL,false,"A Mudkip doll. Place it on a mat or a desk."], ["Smoochum Doll",225,1,1,1000,18,ItemType::DOLL,false,"A Smoochum doll. Place it on a mat or a desk."], ["Cyndaquil Doll",233,1,1,1000,19,ItemType::DOLL,false,"A Cyndaquil doll. Place it on a mat or a desk."], ["Chikorita Doll",241,1,1,1000,20,ItemType::DOLL,false,"A Chikorita doll. Place it on a mat or a desk."], ["Totodile Doll",249,1,1,1000,21,ItemType::DOLL,false,"A Totodile doll. Place it on a mat or a desk."], #* Cushion ["Ball Cushion",419,1,1,500,8,ItemType::CUSHION,false,"A cushion shaped like a PokéBall."], ["Diamon Cushion",420,1,1,500,9,ItemType::CUSHION,false,"A cushion based on Sableye."], ["Fire Cushion",421,1,1,500,10,ItemType::CUSHION,false,"A cushion with a fire emblem imprint."], ["Grass Cushion",422,1,1,500,11,ItemType::CUSHION,false,"A cushion with a grass emblem imprint."], ["Kiss Cushion",427,1,1,500,12,ItemType::CUSHION,false,"A cushion based on Smoochum."], ["Pika Cushion",428,1,1,500,13,ItemType::CUSHION,false,"A cushion based on Pikachu."], ["Round Cushion",429,1,1,500,14,ItemType::CUSHION,false,"A cushion based on Marill."], ["Spin Cushion",430,1,1,500,15,ItemType::CUSHION,false,"A cushion based on Spinda."], ["Water Cushion",435,1,1,500,16,ItemType::CUSHION,false,"A cushion with a water emblem imprint."], ["Zigzag Cushion",436,1,1,500,17,ItemType::CUSHION,false,"A cushion based on Zigzagoon."], #* New Items #* Dolls #Small ["Bulbasaur Doll",240,1,1,1000,26,ItemType::DOLL,false,"A Bulbasaur doll. Place it on a mat or a desk."], ["Squirtle Doll",248,1,1,1000,27,ItemType::DOLL,false,"A Squirtle doll. Place it on a mat or a desk."], ["Charmander Doll",264,1,1,1000,28,ItemType::DOLL,false,"A Charmander doll. Place it on a mat or a desk."], ["Turtwig Doll",192,1,1,1000,29,ItemType::DOLL,false,"A Turtwig doll. Place it on a mat or a desk."], ["Piplup Doll",199,1,1,1000,30,ItemType::DOLL,false,"A Piplup doll. Place it on a mat or a desk."], ["Chimchar Doll",184,1,1,1000,31,ItemType::DOLL,false,"A Chimchar doll. Place it on a mat or a desk."], #Large ["Venusaur Doll",164,1,1,5000,32,ItemType::DOLL,false,"A Venusaur doll. Place it on a mat or a desk."], ["Blastoise Doll",265,1,1,5000,33,ItemType::DOLL,false,"A Blastoise doll. Place it on a mat or a desk."], ["Charizard Doll",272,1,1,5000,34,ItemType::DOLL,false,"A Charizard doll. Place it on a mat or a desk."], ["Snorlax(A) Doll",273,1,1,5000,35,ItemType::DOLL,false,"A Snorlax doll. Place it on a mat or a desk."], ["Rhydon Doll",280,1,1,5000,36,ItemType::DOLL,false,"A Rhydon doll. Place it on a mat or a desk."], ["Magnezone Doll",281,1,1,5000,37,ItemType::DOLL,false,"A Magnezone doll. Place it on a mat or a desk."], ["Wailord Doll",288,1,1,5000,38,ItemType::DOLL,false,"A Wailord doll. Place it on a mat or a desk."], ["Snorlax(B) Doll",289,1,1,5000,39,ItemType::DOLL,false,"A Snorlax doll. Place it on a mat or a desk."], #Small ["Riolu Doll",432,1,1,1000,40,ItemType::DOLL,false,"A Riolu doll. Place it on a mat or a desk."], ["Seedot Doll",433,1,1,1000,41,ItemType::DOLL,false,"A Seedot doll. Place it on a mat or a desk."], ["Lotad Doll",434,1,1,1000,42,ItemType::DOLL,false,"A Lotad doll. Place it on a mat or a desk."], ["Gulpin Doll",440,1,1,1000,43,ItemType::DOLL,false,"A Gulpin doll. Place it on a mat or a desk."], ["Swablu Doll",441,1,1,1000,44,ItemType::DOLL,false,"A Swablu doll. Place it on a mat or a desk."], ["Skitty Doll",442,1,1,1000,45,ItemType::DOLL,false,"A Skitty doll. Place it on a mat or a desk."], ["Azurill Doll",448,1,1,1000,46,ItemType::DOLL,false,"A Azurill doll. Place it on a mat or a desk."], ["Kecleon Doll",449,1,1,1000,47,ItemType::DOLL,false,"A Kecleon doll. Place it on a mat or a desk."], ["Baltoy Doll",450,1,1,1000,48,ItemType::DOLL,false,"A Baltoy doll. Place it on a mat or a desk."], ["Wynaut Doll",456,1,1,1000,49,ItemType::DOLL,false,"A Wynaut doll. Place it on a mat or a desk."], ["Pichu Doll",457,1,1,1000,50,ItemType::DOLL,false,"A Pichu doll. Place it on a mat or a desk."], ["Pikachu Doll",458,1,1,1000,51,ItemType::DOLL,false,"A Pikachu doll. Place it on a mat or a desk."], ["Marill Doll",464,1,1,1000,52,ItemType::DOLL,false,"A Marill doll. Place it on a mat or a desk."], ["Togepi Doll",465,1,1,1000,53,ItemType::DOLL,false,"A Togepi doll. Place it on a mat or a desk."], ["Jigglypuff Doll",466,1,1,1000,54,ItemType::DOLL,false,"A Jigglypuff doll. Place it on a mat or a desk."], ["Meowth Doll",443,1,1,1000,55,ItemType::DOLL,false,"A Meowth doll. Place it on a mat or a desk."], ["Clefairy Doll",444,1,1,1000,56,ItemType::DOLL,false,"A Clefairy doll. Place it on a mat or a desk."], ["Ditto Doll",445,1,1,1000,57,ItemType::DOLL,false,"A Ditto doll. Place it on a mat or a desk."], ["Duskull Doll",446,1,1,1000,58,ItemType::DOLL,false,"A Duskull doll. Place it on a mat or a desk."], ["Plusle Doll",447,1,1,1000,59,ItemType::DOLL,false,"A Plusle doll. Place it on a mat or a desk."], ["Minun Doll",451,1,1,1000,60,ItemType::DOLL,false,"A Minun doll. Place it on a mat or a desk."], ["Weavile Doll",452,1,1,1000,61,ItemType::DOLL,false,"A Weavile doll. Place it on a mat or a desk."], ["Glameow Doll",453,1,1,1000,62,ItemType::DOLL,false,"A Glameow doll. Place it on a mat or a desk."], ["Munchlax Doll",454,1,1,1000,63,ItemType::DOLL,false,"A Munchlax doll. Place it on a mat or a desk."], ["Bonsly Doll",455,1,1,1000,64,ItemType::DOLL,false,"A Bonsly doll. Place it on a mat or a desk."], ["Mime Jr. Doll",459,1,1,1000,65,ItemType::DOLL,false,"A Mime Jr. doll. Place it on a mat or a desk."], ["Wobbuffet Doll",460,1,1,1000,66,ItemType::DOLL,false,"A Wobbuffet doll. Place it on a mat or a desk."], ["Buneary Doll",461,1,1,1000,67,ItemType::DOLL,false,"A Buneary doll. Place it on a mat or a desk."], ["Buizel Doll",462,1,1,1000,68,ItemType::DOLL,false,"A Buizel doll. Place it on a mat or a desk."], ["Mantyke Doll",463,1,1,1000,69,ItemType::DOLL,false,"A Mantyke doll. Place it on a mat or a desk."], ["Chatot Doll",467,1,1,1000,70,ItemType::DOLL,false,"A Chatot doll. Place it on a mat or a desk."], ["Manaphy Doll",468,1,1,1000,71,ItemType::DOLL,false,"A Manaphy Doll doll. Place it on a mat or a desk."], ["Happiny Doll",469,1,1,1000,72,ItemType::DOLL,false,"A Happiny doll. Place it on a mat or a desk."], ["Pachirisu Doll",470,1,1,1000,73,ItemType::DOLL,false,"A Pachirisu doll. Place it on a mat or a desk."], ["Drifloon Doll",471,1,1,1000,74,ItemType::DOLL,false,"A Drifloon doll. Place it on a mat or a desk."], #Medium #ANIMATED ["Drifballoon",472,1,1,3000,75,ItemType::ORNAMENT,false,"A Drifloon balloon. Don't let it fly away!"], #* Ornaments ["Yellow Tent",488,3,3,5000,nil,ItemType::ORNAMENT,false,"A yellow tent to hide in."], ] #=============================================================================== # ■ Holes # They are made like items. # [tile id, width in tiles, height in tiles] # Holes needs to be in Layer 2. #=============================================================================== BASEHOLES=[ [-1], [7,1,2], [22,2,1], [38,2,2], ] #=============================================================================== # ■ Script start here # - Do not touch anything in here if you don't know what you're doing. #=============================================================================== def pbGetBaseItem(item) $PokemonGlobal.baseItemBag[baseItemPocket(item)].push([item,false]) end def getAllDesks items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::DESK end return items end def getAllChairs items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::CHAIR end return items end def getAllPosters items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::POSTER end return items end def getAllPlants items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::PLANT end return items end def getAllMats items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::MAT end return items end def getAllOrnaments items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::ORNAMENT end return items end def getAllDolls items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::DOLL end return items end def getAllCushions items=[] for i in 1...SECRETBASEITEMS.length items.push(i) if baseItemPocket(i)==ItemType::CUSHION end return items end def isItemForDoll?(pos) #return $game_map.data[pos[0],pos[1],1]==ITEMFORDOLL end class PokemonGlobalMetadata attr_accessor :baseinfo attr_accessor :baseItemBag attr_accessor :placedItems attr_accessor :mybaseid attr_accessor :mybaselocation attr_accessor :installed attr_accessor :outdoordata def baseInstalled? return !@installed ? false : @installed end def getBaseOutdoor return !@outdoordata ? false : @outdoordata end def getBaseId return !@mybaseid ? -1 : @mybaseid end def getBaseLocation return !@mybaselocation ? -1 : @mybaselocation end def getPlacedItems(id) @placedItems={} if !@placedItems @placedItems[id]=[] if !@placedItems[id] return @placedItems[id] end def setPlacedInfo(id,x,y,item) @placedItems={} if !@placedItems @placedItems[id]=[] if !@placedItems[id] @placedItems[id].push([x,y,item]) end def baseBag if !@baseItemBag @baseItemBag={} for i in 0...BASEBAGPOCKETS.length @baseItemBag[i]=[] if !@baseItemBag[i] end end end def getBasePocket(pocket) baseBag return @baseItemBag[pocket] end def basePocketLength(pocket) baseBag return @baseItemBag[pocket].length end def notBaseData?(id) return false if !@baseinfo || !@baseinfo[id] return true end def setBaseInfo(id,eventlist,tiledata) @baseinfo={} if !@baseinfo @baseinfo[id].clear if @baseinfo[id] @baseinfo[id]=[eventlist,tiledata] end end def getMaxSecretBagPocket(pocket) return BASEBAGPOCKETS[pocket][1] end class TileDrawingHelper def bltTileWithSize(bitmap,cxTile,cyTile,id) return if !@tileset || id<384 || @tileset.disposed? rect=Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32,32*cxTile,32*cyTile) bitmap.stretch_blt(Rect.new(0,0,32*cxTile,32*cyTile),@tileset,rect) end end def getBaseItemByName(itemname) for i in 0...SECRETBASEITEMS.length return i if baseItemName(i)==itemname end end def baseItemDesc(id) return SECRETBASEITEMS[id][8] end def baseItemEvent(id) return SECRETBASEITEMS[id][5] end def baseItemPocket(id) return SECRETBASEITEMS[id][6] end def isABoard?(id) return SECRETBASEITEMS[id][7] end def isAPoster?(id) return SECRETBASEITEMS[id][6]==ItemType::POSTER end def isADoll?(id) return SECRETBASEITEMS[id][6]==ItemType::DOLL end def isACushion?(id) return SECRETBASEITEMS[id][6]==ItemType::CUSHION end def isAMat?(id) return SECRETBASEITEMS[id][6]==ItemType::MAT end def isADesk?(id) return SECRETBASEITEMS[id][6]==ItemType::DESK end def baseItemName(id) return SECRETBASEITEMS[id][0] end def baseItemCost(id) return SECRETBASEITEMS[id][4] end def baseItemWidth(id) return SECRETBASEITEMS[id][2]*32 end def baseItemHeight(id) return SECRETBASEITEMS[id][3]*32 end def baseItemTileid(id) return SECRETBASEITEMS[id][1]+384 end def getBaseItemBitmap(id) if baseItemEvent(id)!=nil # Load the event bitmap map=load_data(sprintf("Data/Map%03d.%s", ITEMSMAP,$RPGVX ? "rvdata" : "rxdata")) map.events.each do |i, event| if event.id==baseItemEvent(id) dollEvent=Game_BaseEvent.new(nil, event) dollBitmap=AnimatedBitmap.new("Graphics/Characters/"+dollEvent.character_name, dollEvent.character_hue) width = dollBitmap.width / 4 height = dollBitmap.height / 4 sx = dollEvent.pattern * width sy = (dollEvent.direction - 2) / 2 * height iconItem=Bitmap.new(width,height) iconItem.blt(0,0,dollBitmap.bitmap,Rect.new(sx,sy,width,height)) return iconItem end end else # Load bitmap from tileset bitmap=pbGetTileset(SECRETBASETILESET) itemWidth=baseItemWidth(id) itemHeight=baseItemHeight(id) iconItem=Bitmap.new(itemWidth,itemHeight) tileId=baseItemTileid(id) tilehelper=TileDrawingHelper.new(bitmap,nil) tilehelper.bltTileWithSize(iconItem,itemWidth/32,itemHeight/32,tileId) return iconItem end end class Game_Map alias old_setup_bases setup def setup(map_id) old_setup_bases(map_id) if pbGetMapNameFromId(@map_id)==SECRETBASEMAPNAME#"Secret Base" loadSecretBaseEvents end searchForMyBase end def isItemEvent?(event) return true if event!=nil && event.is_a?(Game_BaseEvent) && event.item==true return false end def backToOriginal @map=load_data(sprintf("Data/Map%03d.%s", @map_id,$RPGVX ? "rvdata" : "rxdata")) @events = {} for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i],self) end $PokemonGlobal.baseinfo[@map_id].clear $PokemonGlobal.baseinfo[@map_id]=nil end def reloadBaseEvents @map=load_data(sprintf("Data/Map%03d.%s", @map_id,$RPGVX ? "rvdata" : "rxdata")) @events = {} for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i],self) end loadSecretBaseEvents(true) end def terrain_tag_id(tileid) return @terrain_tags[tileid] end def loadSecretBaseEvents(savedPositions=false) return if !$PokemonGlobal.notBaseData?(@map_id) @realdata=@map.data @map.data=$PokemonGlobal.baseinfo[@map_id][1] for i in 0...$PokemonGlobal.baseinfo[@map_id][0].length+1 savedEvent=$PokemonGlobal.baseinfo[@map_id][0][i] next if savedEvent==nil nEvent=savedEvent.rEvent newId=getNewId itemEvent=Game_BaseEvent.new(@map_id, nEvent) itemEvent.id=newId itemEvent.moveto(savedEvent.x,savedEvent.y) itemEvent.item=true itemEvent.direction=savedEvent.direction if savedPositions itemEvent.itemtileid=savedEvent.itemtileid itemEvent.rEvent=nEvent @events[newId] = itemEvent end end def getNewId newId = 1 while $game_map.events[newId] != nil do newId += 1 end return newId end def copy_event(mapid, eventid, x, y,tileid) map = load_data(sprintf("Data/Map%03d.rxdata", mapid)) map.events.each do |i, event| if event.id == eventid newId=getNewId nEvent=event.clone # Clone the event # Create the new event in new map eMap=Game_BaseEvent.new(@map_id, nEvent) eMap.id=newId eMap.moveto(x,y) eMap.itemtileid=tileid eMap.item=true eMap.rEvent=nEvent @events[newId] = eMap end end end end # Functions for events def movingRightToThis(event=nil) return $game_player.x==event.x && $game_player.y==event.y && $game_player.direction==6 && $game_player.moving? && (Input.press?(Input::RIGHT) || Input.trigger?(Input::RIGHT) || Input.release?(Input::RIGHT)) end def movingLeftToThis(event=nil) return $game_player.x==event.x && $game_player.y==event.y && $game_player.direction==4 && $game_player.moving? && (Input.press?(Input::LEFT) || Input.trigger?(Input::LEFT) || Input.release?(Input::LEFT)) end def movingUpToThis(event) return $game_player.x==event.x && $game_player.y==event.y && $game_player.direction==8 && $game_player.moving? && (Input.press?(Input::UP) || Input.trigger?(Input::UP) || Input.release?(Input::UP)) end def movingDownToThis(event=nil) return $game_player.x==event.x && $game_player.y==event.y && $game_player.direction==2 && $game_player.moving? && (Input.press?(Input::DOWN) || Input.trigger?(Input::DOWN) || Input.release?(Input::DOWN)) end class Game_Event attr_accessor :rEvent def rEvent return !@rEvent ? false : @rEvent end def direction=(value) @direction=value end end class Game_BaseEvent < Game_Event attr_accessor :item attr_accessor :itemtileid end class Spriteset_Map attr_accessor :character_sprites attr_accessor :player alias old_initialize_base initialize def initialize(map=nil) old_initialize_base(map) @player=@playersprite end end def copyMapData baseEvents=[] for i in 0...$game_map.events.length+1 event=$game_map.events[i] baseEvents.push(event) if event.is_a?(Game_BaseEvent) end $PokemonGlobal.setBaseInfo($game_map.map_id,baseEvents,$game_map.data) end def placeItemInBase(item,pos) x=pos[0] y=pos[1] width=baseItemWidth(item)/32 height=baseItemHeight(item)/32 map = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id)) tilesets=load_data("Data/Tilesets.rxdata") tileset=tilesets[map.tileset_id] priorities=tileset.priorities passages=tileset.passages # Check if it's an event item if baseItemEvent(item) tileid=baseItemTileid(item) $game_map.copy_event(ITEMSMAP,baseItemEvent(item),x,y,tileid) else # Draw a tile for i in 0...width for e in 0...height tileid=baseItemTileid(item)+i+(e*8) layer=priorities[tileid]==0 ? 1 : 2 #layer=2 if passages[tileid] & 0x80 == 0x80 # Counter $game_map.data[x+i,y+e,layer]=tileid end end end copyMapData end #=============================================================================== # PC System #=============================================================================== class Game_Character def screen_x_scroll(scroll) return (@real_x - scroll + 3) / 4 + (Game_Map::TILEWIDTH/2) end def screen_y_scroll(scroll) y = (@real_y - scroll + 3) / 4 + (Game_Map::TILEHEIGHT) if jumping? if @jump_count >= @jump_peak n = @jump_count - @jump_peak else n = @jump_peak - @jump_count end return y - (@jump_peak * @jump_peak - n * n) / 2 else return y end end end class DecorationMap attr_accessor :scroll def initialize(viewport) $scene.disposeSpritesets @map=load_data(sprintf("Data/Map%03d.rxdata",$game_map.map_id)) @viewport=Viewport.new(viewport.rect.x,viewport.rect.y,viewport.rect.width, viewport.rect.height) @viewport.z=99999 @totalscroll=[0,0] pbLoad end def pbLoad @scroll=[0,0] @bitmap=BitmapWrapper.new(@map.width*32,@map.height*32) tilesets=load_data("Data/Tilesets.rxdata") @tileset=tilesets[@map.tileset_id] helper=TileDrawingHelper.fromTileset(@tileset) for y in 0...@map.height for x in 0...@map.width for z in 0..2 id=$game_map.data[x,y,z] id=0 if !id helper.bltTile(@bitmap,x*32,y*32,id) end end end @rsprite=Sprite_Character.new(nil, $game_player) x=@rsprite.x-16 y=@rsprite.y-32 @rsprite.dispose @scroll[0]+=x-$game_player.x*32 @scroll[1]+=y-$game_player.y*32 @mapSprite=Sprite.new(@viewport) @mapSprite.bitmap=@bitmap @mapSprite.x+=@scroll[0] @mapSprite.y+=@scroll[1] @character_sprites = [] for i in $game_map.events.keys.sort sprite=Sprite_Character.new(@viewport, $game_map.events[i]) sprite.x=$game_map.events[i].screen_x_scroll(0) sprite.y=$game_map.events[i].screen_y_scroll(0) sprite.x+=@scroll[0] sprite.y+=@scroll[1] @character_sprites.push(sprite) end @scroll=[0,0] end def pbReloadTiles @bitmap=BitmapWrapper.new(@map.width*32,@map.height*32) helper=TileDrawingHelper.fromTileset(@tileset) for y in 0...@map.height for x in 0...@map.width for z in 0..2 id=$game_map.data[x,y,z] id=0 if !id helper.bltTile(@bitmap,x*32,y*32,id) end end end @mapSprite.bitmap=@bitmap end def pbReloadEvents for sprite in @character_sprites sprite.dispose end @rsprite=Sprite_Character.new(nil, $game_player) x=@rsprite.x-16 y=@rsprite.y-32 @rsprite.dispose @character_sprites.clear for i in $game_map.events.keys.sort sprite=Sprite_Character.new(@viewport, $game_map.events[i]) sprite.x=$game_map.events[i].screen_x_scroll(0) sprite.y=$game_map.events[i].screen_y_scroll(0) sprite.x+=x-$game_player.x*32+@totalscroll[0] sprite.y+=y-$game_player.y*32+@totalscroll[1] @character_sprites.push(sprite) end end def reload pbReloadTiles pbReloadEvents end def disposed? @mapSprite.disposed? end def color return @mapSprite.color end def color=(value) @mapSprite.color=value for sprite in @character_sprites sprite.color=value end end def visible return @mapSprite.visible end def visible=(value) @mapSprite.visible=value for sprite in @character_sprites sprite.visible=value end end def dispose @mapSprite.dispose for sprite in @character_sprites sprite.dispose end $scene.createSpritesets end def updateScrollPos @mapSprite.x+=@scroll[0] @mapSprite.y+=@scroll[1] for sprite in @character_sprites sprite.x+=@scroll[0] sprite.y+=@scroll[1] end @totalscroll[0]+=@scroll[0] @totalscroll[1]+=@scroll[1] @scroll=[0,0] end end def Kernel.pbShowCommandsBase(msgwindow,commands=nil,cmdIfCancel=0,defaultCmd=0) ret=0 if commands cmdwindow=Window_CommandPokemonEx.new(commands) cmdwindow.z=99999 cmdwindow.visible=true cmdwindow.resizeToFit(cmdwindow.commands) pbPositionNearMsgWindow(cmdwindow,msgwindow,:right) cmdwindow.index=defaultCmd command=0 loop do Graphics.update Input.update cmdwindow.update msgwindow.update if msgwindow yield if block_given? if Input.trigger?(Input::B) if cmdIfCancel>0 command=cmdIfCancel-1 break elsif cmdIfCancel<0 command=cmdIfCancel break end end if Input.trigger?(Input::C) command=cmdwindow.index break end end ret=command cmdwindow.dispose Input.update end return ret end def Kernel.pbMessageBase(message,commands=nil,cmdIfCancel=0,skin=nil,defaultCmd=0,&block) ret=0 msgwindow=Kernel.pbCreateMessageWindow(nil,skin) if commands ret=Kernel.pbMessageDisplayBase(msgwindow,message,true, proc {|msgwindow| next Kernel.pbShowCommandsBase(msgwindow,commands,cmdIfCancel,defaultCmd,&block) },&block) else Kernel.pbMessageDisplayBase(msgwindow,message,&block) end Kernel.pbDisposeMessageWindow(msgwindow) Input.update return ret end def Kernel.pbMessageDisplayBase(msgwindow,message,letterbyletter=true,commandProc=nil) return if !msgwindow oldletterbyletter=msgwindow.letterbyletter msgwindow.letterbyletter=(letterbyletter ? true : false) ret=nil count=0 commands=nil facewindow=nil goldwindow=nil coinwindow=nil cmdvariable=0 cmdIfCancel=0 msgwindow.waitcount=0 autoresume=false text=message.clone msgback=nil linecount=(DEFAULTSCREENHEIGHT>400) ? 3 : 2 ### Text replacement text.gsub!(/\\\\/,"\5") if $game_actors text.gsub!(/\\[Nn]\[([1-8])\]/){ m=$1.to_i next $game_actors[m].name } end text.gsub!(/\\[Ss][Ii][Gg][Nn]\[([^\]]*)\]/){ next "\\op\\cl\\ts[]\\w["+$1+"]" } text.gsub!(/\\[Pp][Nn]/,$Trainer.name) if $Trainer text.gsub!(/\\[Pp][Mm]/,_INTL("${1}",$Trainer.money)) if $Trainer text.gsub!(/\\[Nn]/,"\n") text.gsub!(/\\\[([0-9A-Fa-f]{8,8})\]/){ "<c2="+$1+">" } text.gsub!(/\\[Pp][Gg]/,"") text.gsub!(/\\[Pp][Oo][Gg]/,"") text.gsub!(/\\[Bb]/,"<c2=6546675A>") text.gsub!(/\\[Rr]/,"<c2=043C675A>") text.gsub!(/\\1/,"\1") colortag="" isDarkSkin=isDarkWindowskin(msgwindow.windowskin) if ($game_message && $game_message.background>0) || ($game_system && $game_system.respond_to?("message_frame") && $game_system.message_frame != 0) colortag=getSkinColor(msgwindow.windowskin,0,true) else colortag=getSkinColor(msgwindow.windowskin,0,isDarkSkin) end text.gsub!(/\\[Cc]\[([0-9]+)\]/){ m=$1.to_i next getSkinColor(msgwindow.windowskin,m,isDarkSkin) } begin last_text = text.clone text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } end until text == last_text begin last_text = text.clone text.gsub!(/\\[Ll]\[([0-9]+)\]/) { linecount=[1,$1.to_i].max; next "" } end until text == last_text text=colortag+text ### Controls textchunks=[] controls=[] while text[/(?:\\([WwFf]|[Ff][Ff]|[Tt][Ss]|[Cc][Ll]|[Mm][Ee]|[Ss][Ee]|[Ww][Tt]|[Ww][Tt][Nn][Pp]|[Cc][Hh])\[([^\]]*)\]|\\([Gg]|[Cc][Nn]|[Ww][Dd]|[Ww][Mm]|[Oo][Pp]|[Cc][Ll]|[Ww][Uu]|[\.]|[\|]|[\!]|[\x5E])())/i] textchunks.push($~.pre_match) if $~[1] controls.push([$~[1].downcase,$~[2],-1]) else controls.push([$~[3].downcase,"",-1]) end text=$~.post_match end textchunks.push(text) for chunk in textchunks chunk.gsub!(/\005/,"\\") end textlen=0 for i in 0...controls.length control=controls[i][0] if control=="wt" || control=="wtnp" || control=="." || control=="|" textchunks[i]+="\2" elsif control=="!" textchunks[i]+="\1" end textlen+=toUnformattedText(textchunks[i]).scan(/./m).length controls[i][2]=textlen end text=textchunks.join("") unformattedText=toUnformattedText(text) signWaitCount=0 haveSpecialClose=false specialCloseSE="" for i in 0...controls.length control=controls[i][0] param=controls[i][1] if control=="f" facewindow.dispose if facewindow facewindow=PictureWindow.new("Graphics/Pictures/#{param}") elsif control=="op" signWaitCount=21 elsif control=="cl" text=text.sub(/\001\z/,"") # fix: '$' can match end of line as well haveSpecialClose=true specialCloseSE=param elsif control=="se" && controls[i][2]==0 startSE=param controls[i]=nil elsif control=="ff" facewindow.dispose if facewindow facewindow=FaceWindowVX.new(param) elsif control=="ch" cmds=param.clone cmdvariable=pbCsvPosInt!(cmds) cmdIfCancel=pbCsvField!(cmds).to_i commands=[] while cmds.length>0 commands.push(pbCsvField!(cmds)) end elsif control=="wtnp" || control=="^" text=text.sub(/\001\z/,"") # fix: '$' can match end of line as well end end if startSE!=nil pbSEPlay(pbStringToAudioFile(startSE)) elsif signWaitCount==0 && letterbyletter pbPlayDecisionSE() end ########## Position message window ############## pbRepositionMessageWindow(msgwindow,linecount) if $game_message && $game_message.background==1 msgback=IconSprite.new(0,msgwindow.y,msgwindow.viewport) msgback.z=msgwindow.z-1 msgback.setBitmap("Graphics/System/MessageBack") end if facewindow pbPositionNearMsgWindow(facewindow,msgwindow,:left) facewindow.viewport=msgwindow.viewport facewindow.z=msgwindow.z end atTop=(msgwindow.y==0) ########## Show text ############################# msgwindow.text=text Graphics.frame_reset if Graphics.frame_rate>40 begin if signWaitCount>0 signWaitCount-=1 if atTop msgwindow.y=-(msgwindow.height*(signWaitCount)/20) else msgwindow.y=DEFAULTSCREENHEIGHT-(msgwindow.height*(20-signWaitCount)/20) end end for i in 0...controls.length if controls[i] && controls[i][2]<=msgwindow.position && msgwindow.waitcount==0 control=controls[i][0] param=controls[i][1] if control=="f" facewindow.dispose if facewindow facewindow=PictureWindow.new("Graphics/Pictures/#{param}") pbPositionNearMsgWindow(facewindow,msgwindow,:left) facewindow.viewport=msgwindow.viewport facewindow.z=msgwindow.z elsif control=="ts" if param=="" msgwindow.textspeed=-999 else msgwindow.textspeed=param.to_i end elsif control=="ff" facewindow.dispose if facewindow facewindow=FaceWindowVX.new(param) pbPositionNearMsgWindow(facewindow,msgwindow,:left) facewindow.viewport=msgwindow.viewport facewindow.z=msgwindow.z elsif control=="g" # Display gold window goldwindow.dispose if goldwindow goldwindow=pbDisplayGoldWindow(msgwindow) elsif control=="cn" # Display coins window coinwindow.dispose if coinwindow coinwindow=pbDisplayCoinsWindow(msgwindow,goldwindow) elsif control=="wu" msgwindow.y=0 atTop=true msgback.y=msgwindow.y if msgback pbPositionNearMsgWindow(facewindow,msgwindow,:left) msgwindow.y=-(msgwindow.height*(signWaitCount)/20) elsif control=="wm" atTop=false msgwindow.y=(DEFAULTSCREENHEIGHT/2)-(msgwindow.height/2) msgback.y=msgwindow.y if msgback pbPositionNearMsgWindow(facewindow,msgwindow,:left) elsif control=="wd" atTop=false msgwindow.y=(DEFAULTSCREENHEIGHT)-(msgwindow.height) msgback.y=msgwindow.y if msgback pbPositionNearMsgWindow(facewindow,msgwindow,:left) msgwindow.y=DEFAULTSCREENHEIGHT-(msgwindow.height*(20-signWaitCount)/20) elsif control=="." msgwindow.waitcount+=Graphics.frame_rate/4 elsif control=="|" msgwindow.waitcount+=Graphics.frame_rate elsif control=="wt" # Wait param=param.sub(/\A\s+/,"").sub(/\s+\z/,"") msgwindow.waitcount+=param.to_i*2 elsif control=="w" # Windowskin if param=="" msgwindow.windowskin=nil else msgwindow.setSkin("Graphics/Windowskins/#{param}") end msgwindow.width=msgwindow.width # Necessary evil elsif control=="^" # Wait, no pause autoresume=true elsif control=="wtnp" # Wait, no pause param=param.sub(/\A\s+/,"").sub(/\s+\z/,"") msgwindow.waitcount=param.to_i*2 autoresume=true elsif control=="se" # Play SE pbSEPlay(pbStringToAudioFile(param)) elsif control=="me" # Play ME pbMEPlay(pbStringToAudioFile(param)) end controls[i]=nil end end break if !letterbyletter Graphics.update Input.update facewindow.update if facewindow if $DEBUG && Input.trigger?(Input::F6) pbRecord(unformattedText) end if autoresume && msgwindow.waitcount==0 msgwindow.resume if msgwindow.busy? break if !msgwindow.busy? end if (Input.trigger?(Input::C) || Input.trigger?(Input::B)) if msgwindow.busy? pbPlayDecisionSE() if msgwindow.pausing? msgwindow.resume else break if signWaitCount==0 end end msgwindow.update yield if block_given? end until (!letterbyletter || commandProc || commands) && !msgwindow.busy? Input.update # Must call Input.update again to avoid extra triggers msgwindow.letterbyletter=oldletterbyletter if commands $game_variables[cmdvariable]=Kernel.pbShowCommands( msgwindow,commands,cmdIfCancel) $game_map.need_refresh = true if $game_map end if commandProc ret=commandProc.call(msgwindow) end msgback.dispose if msgback goldwindow.dispose if goldwindow coinwindow.dispose if coinwindow facewindow.dispose if facewindow if haveSpecialClose pbSEPlay(pbStringToAudioFile(specialCloseSE)) atTop=(msgwindow.y==0) for i in 0..20 if atTop msgwindow.y=-(msgwindow.height*(i)/20) else msgwindow.y=DEFAULTSCREENHEIGHT-(msgwindow.height*(20-i)/20) end Graphics.update Input.update msgwindow.update end end return ret end def Kernel.pbConfirmMessageBase(message,&block) return (Kernel.pbMessageBase(message,[_INTL("Yes"),_INTL("No")],2,&block)==0) end class PokemonDecoration def initialize; end def pbStartScene @viewport=Viewport.new(0,0,Graphics.width,DEFAULTSCREENHEIGHT) @viewport.z=999999 @sprites={} end def getSecretArrow if $Trainer.gender==1 bitmapname=_INTL("Graphics/Pictures/secretBaseArrow_Green{1}",$Trainer.metaID) return BitmapCache.load_bitmap(bitmapname) else bitmapname=_INTL("Graphics/Pictures/secretBaseArrow_Red{1}",$Trainer.metaID) return BitmapCache.load_bitmap(bitmapname) end end def getMapPassable(x,y) for event in $game_map.events.values return false if event.x==x && event.y==y end if $game_map.data[x,y,0] return false if isPosterWall($game_map.data[x,y,0]) end return $game_map.passable?(x,y,0) end def isPosterWall(tileid) #map = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id)) #tilesets=load_data("Data/Tilesets.rxdata") #tileset=tilesets[map.tileset_id] #priorities=tileset.priorities #passages=tileset.passages #pass=[] #pass[0]=passages[tileid] & 0x01 == 0x01 # Down arrow #pass[1]=passages[tileid] & 0x02 == 0x02 # Left arrow #pass[2]=passages[tileid] & 0x04 == 0x04 # Up arrow #pass[3]=passages[tileid] & 0x08 == 0x08 # Up arrow #if pass[0]==true && pass[1]==false && # pass[2]==false && pass[3]==false # return true #end if $game_map.terrain_tag_id(tileid)==WALLTERRAINTAG return true end return false end def canPlaceItem?(item,pos) map = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id)) tilesets=load_data("Data/Tilesets.rxdata") tileset=tilesets[map.tileset_id] priorities=tileset.priorities passages=tileset.passages width=baseItemWidth(item)/32 height=baseItemHeight(item)/32 # Do not put anything above player! for w in 0...width for h in 0...height tileid=baseItemTileid(item)+w+(h*8) notblocked=passages[tileid] & 0x0f == 0x0f if notblocked && pos[0]+w==$game_player.x && pos[1]+h==$game_player.y return false end end end # Avoids to put items above others if !DOLLSEVERYWHERE && !(isADoll?(item) || isACushion?(item)) for e in 0...height tileid=baseItemTileid(item)+(e*8) prio=priorities[tileid] #prio=1 if passages[tileid] & 0x80 == 0x80 next if prio>0 for i in 0...width tileid=baseItemTileid(item)+i+(e*8) prio=priorities[tileid] #prio=1 if passages[tileid] & 0x80 == 0x80 pass=passages[tileid] & 0x0f == 0x0f if $game_map.data[pos[0]+i,pos[1]+e,1]!=0 && prio==0 # Check for holes isahole=thereIsAHole?([pos[0]+i,pos[1]+e]) if isahole && isABoard?(item) holewidth=isahole[0] holeheight=isahole[1] positions=getTopLeftWithATileHole([pos[0]+i,pos[1]+e]) if positions[0]==pos[0] && positions[1]==pos[1] && holewidth==width && holeheight==height return true end end return false elsif $game_map.data[pos[0]+i,pos[1]+e,2]!=0 && prio==0 topleft=getTopLeftWithATile(pos) if !topleft.is_a?(Range) if pos[1]+e!=topleft[1] return false end end end end end end # Check if it's a poster if isAPoster?(item) putInWall=true for i in 0...width for e in 0...height tileid=baseItemTileid(item)+i+(e*8) for w in 0...width for h in 0...height alreadyp=$game_map.data[pos[0]+w,pos[1]+h,1] newp=isPosterWall($game_map.data[pos[0]+w,pos[1]+h,0]) if !newp || alreadyp>0 putInWall=false end end end return true if putInWall return false end end # Placing dolls only in mats and counter tiles elsif isADoll?(item) || isACushion?(item) placed=getItemIn(pos) # If it's a mat or a counter tile and it's not an interactive one if isAMat?(placed) && baseItemEvent(placed)==nil return true elsif isADesk?(placed) && baseItemEvent(placed)==nil tileid=$game_map.data[pos[0],pos[1],1] counter=passages[tileid] & 0x80 == 0x80 return true if counter elsif DOLLSEVERYWHERE newp=getMapPassable(pos[0],pos[1]) if $game_map.terrain_tag(pos[0],pos[1])==GROUNDDECORATION return false # Avoid to put tiles in layer 0 decorations end return true if newp end return false else for i in 0...width for e in 0...height tileid=baseItemTileid(item)+i+(e*8) prio=priorities[tileid] pass=passages[tileid] & 0x0f == 0x0f mappass=getMapPassable(pos[0]+i,pos[1]+e) upasable=true #counter=passages[tileid] & 0x80 == 0x80 # Is first line passable? (0...width).each do |w| np=getMapPassable(pos[0]+w,pos[1]) upasable=false if !np end # Make counter tiles priorities if counter upasable=false prio=1 end if !upasable && prio>0 (0...height).each do |h| (0...width).each do |w| # Tile to place data tileplace=baseItemTileid(item)+w+(h*8) tileprio=priorities[tileplace] placep=passages[tileplace] & 0x0f == 0x0f counter=passages[tileplace] & 0x80 == 0x80 #tileprio=1 if counter # Tile in map data if tileprio==0 && $game_map.terrain_tag(pos[0]+w,pos[1]+h)==GROUNDDECORATION return false # Avoid to put tiles in layer 0 decorations end newp=getMapPassable(pos[0]+w,pos[1]+h) return false if h==0 && !newp && tileprio==0 return false if h>0 && !newp end end return true elsif mappass for w in 0...width for h in 0...height tileplace=baseItemTileid(item)+w+(h*8) newp=getMapPassable(pos[0]+w,pos[1]+h) tileprio=priorities[tileplace] if tileprio==0 && $game_map.terrain_tag(pos[0]+w,pos[1]+h)==GROUNDDECORATION return false # Avoid to put tiles in layer 0 decorations end #tileprio=1 if passages[tileplace] & 0x80 == 0x80 return false if !newp end end return true end end end end return false end # Get a placed item def getItemIn(pos) x=@pos[0] y=@pos[1] for i in 1...SECRETBASEITEMS.length thisId=baseItemTileid(i) width=baseItemWidth(i)/32 height=baseItemHeight(i)/32 (0...height).each do |h| (0...width).each do |w| actualTile=baseItemTileid(i)+w+(h*8) for l in 0...3 if actualTile==$game_map.data[x,y,l] return i end end end end end end def getTopLeftWithATileHole(pos) x=pos[0] y=pos[1] for i in 1...BASEHOLES.length thisId=BASEHOLES[i][0]+384 width=BASEHOLES[i][1] height=BASEHOLES[i][2] (0...height).each do |h| (0...width).each do |w| actualTile=(BASEHOLES[i][0]+384)+w+(h*8) for l in 0...3 # Get top item if actualTile==$game_map.data[x,y,l] return getTopLeftHole(i,actualTile,x,y) end end end end end return false end def getTopLeftHole(item,actualTile,x,y) width=BASEHOLES[item][1] height=BASEHOLES[item][2] (0...height).each do |h| (0...width).each do |w| if (BASEHOLES[item][0]+384)+w+(h*8)==actualTile x-=w y-=h end end end return [x,y] end def thereIsAHole?(pos) x=pos[0] y=pos[1] for i in 1...BASEHOLES.length thisId=BASEHOLES[i][0]+384 width=BASEHOLES[i][1] height=BASEHOLES[i][2] (0...height).each do |h| (0...width).each do |w| actualTile=(BASEHOLES[i][0]+384)+w+(h*8) for l in 0...3 # Get top item if actualTile==$game_map.data[x,y,l] return [width,height] end end end end end return false end # Get top left position of a tiled item def getTopLeftWithATile(pos) x=@pos[0] y=@pos[1] for i in 1...SECRETBASEITEMS.length thisId=baseItemTileid(i) width=baseItemWidth(i)/32 height=baseItemHeight(i)/32 (0...height).each do |h| (0...width).each do |w| actualTile=baseItemTileid(i)+w+(h*8) for l in 0...3 # Get top item if actualTile==$game_map.data[x,y,l] return getTopLeft(i,actualTile,x,y) end end end end end end # Delete items def deleteItemIn(pos,delete=true) x=pos[0] y=pos[1] isEvent=false for i in 1...SECRETBASEITEMS.length thisId=baseItemTileid(i) width=baseItemWidth(i)/32 height=baseItemHeight(i)/32 # Check if there's an event for event in $game_map.events.values if !isEvent && event.is_a?(Game_BaseEvent) && event.x==x && event.y==y isEvent=true itemEvent=event end end if isEvent return true if !delete deleteEvent(@pos) return else (0...height).each do |h| (0...width).each do |w| actualTile=baseItemTileid(i)+w+(h*8) # Get top item tileMiddle=$game_map.data[x,y,1] tileTop=$game_map.data[x,y,2] # Delete top tile if tileTop>0 && actualTile==tileTop return true if !delete # Delete item topleft=getTopLeft(i,actualTile,x,y) deleteTiledItem(i,topleft) return # Delete middle tile elsif actualTile==tileMiddle && tileTop==0 return true if !delete topleft=getTopLeft(i,actualTile,x,y) # Delete item if isABoard?(i) && $game_player.x>=topleft[0] && $game_player.x<topleft[0]+width && $game_player.y>=topleft[1] && $game_player.y<topleft[1]+height Kernel.pbMessageBase("You can't delete this right now.") else deleteTiledItem(i,topleft) end return end end end end end return false if !delete end # Delete event def deleteEvent(pos) x=pos[0] y=pos[1] for event in $game_map.events.values if event.x==x && event.y==y thisEvent=event end end return if thisEvent==nil # Back item to PC placedInfo=$PokemonGlobal.getPlacedItems($game_map.map_id) for i in 0...placedInfo.length actualItem=placedInfo[i] if actualItem[0]==x && actualItem[1]==y && baseItemTileid(actualItem[2][0])==thisEvent.itemtileid actualItem[2][1]=false end end savedEvent=$PokemonGlobal.baseinfo[$game_map.map_id][0] for i in 0...savedEvent.length+1 next if savedEvent[i]==nil if savedEvent[i]==thisEvent savedEvent[i]=nil savedEvent.compact! $game_map.reloadBaseEvents copyMapData return end end end # Delete a tiled item def deleteTiledItem(item,pos) x=pos[0] y=pos[1] width=baseItemWidth(item)/32 height=baseItemHeight(item)/32 map = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id)) tilesets=load_data("Data/Tilesets.rxdata") tileset=tilesets[map.tileset_id] priorities=tileset.priorities passages=tileset.passages # Back item to PC placedInfo=$PokemonGlobal.getPlacedItems($game_map.map_id) for i in 0...placedInfo.length actualItem=placedInfo[i] if actualItem[0]==x && actualItem[1]==y && baseItemTileid(actualItem[2][0])==baseItemTileid(item) actualItem[2][1]=false end end (0...height).each do |h| (0...width).each do |w| tileid=baseItemTileid(item)+w+(h*8) layer=priorities[tileid]==0 ? 1 : 2 #layer=2 if passages[tileid] & 0x80 == 0x80 # Delete also decorations over a mat or a desk if (isAMat?(item) || isADesk?(item)) && baseItemEvent(item)==nil deleteEvent([x+w,y+h]) end $game_map.data[x+w,y+h,layer]=map.data[x+w,y+h,layer] end end end # Get top left for deleting def getTopLeft(item,actualTile,x,y) width=baseItemWidth(item)/32 height=baseItemHeight(item)/32 (0...height).each do |h| (0...width).each do |w| if baseItemTileid(item)+w+(h*8)==actualTile x-=w y-=h end end end return [x,y] end def pbCreatePutAway @sprites["map"]=DecorationMap.new(@viewport) @sprites["item"]=ItemBaseSprite.new(@viewport) @sprites["item"].bitmap=RPG::Cache.picture("secretBaseDeleter") @rsprite=Sprite_Character.new(nil, $game_player) x=@rsprite.x-16 y=@rsprite.y-32 @rsprite.dispose @sprites["item"].x=x @sprites["item"].y=y @pos=[$game_player.x,$game_player.y] @sprites["arrow"]=Sprite.new(@viewport) @sprites["arrow"].bitmap=getSecretArrow @sprites["arrow"].oy=@sprites["arrow"].bitmap.height @sprites["arrow"].x=@sprites["item"].x+@sprites["item"].bitmap.width @sprites["arrow"].y=@sprites["item"].y+@sprites["item"].bitmap.height @sprites["item"].update end def pbPutAway loop do Graphics.update Input.update @sprites["item"].update if Input.trigger?(Input::UP) @sprites["map"].scroll[1]+=32 @sprites["map"].updateScrollPos @pos[1]-=1 elsif Input.trigger?(Input::DOWN) @sprites["map"].scroll[1]-=32 @sprites["map"].updateScrollPos @pos[1]+=1 elsif Input.trigger?(Input::RIGHT) @sprites["map"].scroll[0]-=32 @sprites["map"].updateScrollPos @pos[0]+=1 elsif Input.trigger?(Input::LEFT) @sprites["map"].scroll[0]+=32 @sprites["map"].updateScrollPos @pos[0]-=1 elsif Input.trigger?(Input::C) @sprites["item"].makeVisible if !deleteItemIn(@pos,false) Kernel.pbMessageBase("There is no decoration item here.") else if Kernel.pbConfirmMessageBase("Return this decoration to the PC?") deleteItemIn(@pos) @sprites["map"].reload end end elsif Input.trigger?(Input::B) break end end @sprites["item"].dispose @sprites["arrow"].dispose @sprites["map"].dispose end def pbCreatePlaceItem(item) @placed=false @sprites["map"]=DecorationMap.new(@viewport) @sprites["item"]=ItemBaseSprite.new(@viewport) @sprites["item"].bitmap=getBaseItemBitmap(item[0]) @rsprite=Sprite_Character.new(nil, $game_player) x=@rsprite.x-16 y=@rsprite.y-32 @rsprite.dispose @sprites["item"].x=x @sprites["item"].y=y if baseItemEvent(item[0])!=nil @sprites["item"].ox=@sprites["item"].bitmap.width/2-16 @sprites["item"].oy=@sprites["item"].bitmap.height-32 end @pos=[$game_player.x,$game_player.y] @sprites["arrow"]=Sprite.new(@viewport) @sprites["arrow"].bitmap=getSecretArrow @sprites["arrow"].oy=@sprites["arrow"].bitmap.height @sprites["arrow"].x=@sprites["item"].x+@sprites["item"].bitmap.width @sprites["arrow"].y=@sprites["item"].y+@sprites["item"].bitmap.height @sprites["arrow"].x-=@sprites["item"].ox @sprites["arrow"].y-=@sprites["item"].oy @sprites["item"].update end def pbPlaceItem(item) loop do Graphics.update Input.update @sprites["item"].update if Input.trigger?(Input::UP) @sprites["map"].scroll[1]+=32 @sprites["map"].updateScrollPos @pos[1]-=1 elsif Input.trigger?(Input::DOWN) @sprites["map"].scroll[1]-=32 @sprites["map"].updateScrollPos @pos[1]+=1 elsif Input.trigger?(Input::RIGHT) @sprites["map"].scroll[0]-=32 @sprites["map"].updateScrollPos @pos[0]+=1 elsif Input.trigger?(Input::LEFT) @sprites["map"].scroll[0]+=32 @sprites["map"].updateScrollPos @pos[0]-=1 elsif Input.trigger?(Input::C) @sprites["item"].makeVisible if canPlaceItem?(item[0],@pos) placeItemInBase(item[0],@pos) $PokemonGlobal.setPlacedInfo($game_map.map_id,@pos[0],@pos[1],item) @placed=true break else Kernel.pbMessageBase("It can't be placed here.") $scene.disposeSpritesets end elsif Input.trigger?(Input::B) @placed=false break end end @sprites["item"].dispose @sprites["arrow"].dispose @sprites["map"].dispose return @placed end end ####### Bitmap save class Bitmap RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ppi', 'i') def last_row_address return 0 if disposed? RtlMoveMemory.call(buf=[0].pack('L'), __id__*2+16, 4) RtlMoveMemory.call(buf, buf.unpack('L')[0]+8 , 4) RtlMoveMemory.call(buf, buf.unpack('L')[0]+16, 4) buf.unpack('L')[0] end def bytesize width * height * 4 end def get_data data = [].pack('x') * bytesize RtlMoveMemory.call(data, last_row_address, data.bytesize) data end def set_data(data) RtlMoveMemory.call(last_row_address, data, data.bytesize) end def get_data_ptr data = String.new RtlMoveMemory.call(data.__id__*2, [0x2007].pack('L'), 4) RtlMoveMemory.call(data.__id__*2+8, [bytesize,last_row_address].pack('L2'), 8) def data.free() RtlMoveMemory.call(__id__*2, String.new, 16) end return data unless block_given? yield data ensure data.free end def _dump(level) get_data_ptr do |data| dump = Marshal.dump([width, height, Zlib::Deflate.deflate(data, 9)]) dump end end def self._load(dump) width, height, data = *Marshal.load(dump) data.replace(Zlib::Inflate.inflate(data)) bitmap = new(width, height) bitmap.set_data(data) bitmap end def export(filename) export_png("#{filename}.png") end def export_png(filename) data, i = get_data, 0 (0).step(data.bytesize-4, 4) do |i| data[i,3] = data[i,3].reverse! end deflate = Zlib::Deflate.new(9) null_char, w4 = [].pack('x'), width*4 (data.bytesize-w4).step(0, -w4) {|i| deflate << null_char << data[i,w4]} data.replace(deflate.finish) deflate.close File.open(filename, 'wb') do |file| def file.write_chunk(chunk) write([chunk.bytesize-4].pack('N')) write(chunk) write([Zlib.crc32(chunk)].pack('N')) end file.write("\211PNG\r\n\32\n") file.write_chunk(['IHDR',width,height,8,6,0,0,0].pack('a4N2C5')) file.write_chunk(data.insert(0, 'IDAT')) file.write_chunk('IEND') end end end class String alias getbyte [] alias setbyte []= alias bytesize size end class Font def marshal_dump() end def marshal_load(dump) end end module Graphics FindWindow = Win32API.new('user32', 'FindWindow' , 'pp' , 'i') GetDC = Win32API.new('user32', 'GetDC' , 'i' , 'i') ReleaseDC = Win32API.new('user32', 'ReleaseDC' , 'ii' , 'i') BitBlt = Win32API.new('gdi32' , 'BitBlt' , 'iiiiiiiii', 'i') CreateCompatibleBitmap = Win32API.new('gdi32' , 'CreateCompatibleBitmap', 'iii' , 'i') CreateCompatibleDC = Win32API.new('gdi32' , 'CreateCompatibleDC' , 'i' , 'i') DeleteDC = Win32API.new('gdi32' , 'DeleteDC' , 'i' , 'i') DeleteObject = Win32API.new('gdi32' , 'DeleteObject' , 'i' , 'i') GetDIBits = Win32API.new('gdi32' , 'GetDIBits' , 'iiiiipi' , 'i') SelectObject = Win32API.new('gdi32' , 'SelectObject' , 'ii' , 'i') def self.snap_to_bitmap bitmap = Bitmap.new(width, height) info = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL') hDC = GetDC.call(hwnd) bmp_hDC = CreateCompatibleDC.call(hDC) bmp_hBM = CreateCompatibleBitmap.call(hDC, width, height) bmp_obj = SelectObject.call(bmp_hDC, bmp_hBM) BitBlt.call(bmp_hDC, 0, 0, width, height, hDC, 0, 0, 0xCC0020) GetDIBits.call(bmp_hDC, bmp_hBM, 0, height, bitmap.last_row_address, info, 0) SelectObject.call(bmp_hDC, bmp_obj) DeleteObject.call(bmp_hBM) DeleteDC.call(bmp_hDC) ReleaseDC.call(hwnd, hDC) bitmap end class << self def hwnd() @hwnd ||= FindWindow.call('RGSS Player', nil) end def width() 640 end unless method_defined?(:width) def height() 480 end unless method_defined?(:height) def export(filename=Time.now.strftime("snapshot %Y-%m-%d %Hh%Mm%Ss #{frame_count}")) bitmap = snap_to_bitmap bitmap.export(filename) bitmap.dispose end alias save export alias snapshot export end end #################### class ItemBaseSprite < RPG::Sprite def initialize(*args) super @frameEffect=0 end def makeVisible self.visible=true @frameEffect=0 end def update super @frameEffect+=1 if @frameEffect==12 self.visible=false elsif @frameEffect==24 self.visible=true @frameEffect=0 end end end class Window_PocketsList < Window_DrawableCommand attr_accessor :stock def initialize(stock,x,y,width,height,viewport=nil) @stock=stock super(x,y,width,height,viewport) @baseColor=Color.new(88,88,80) @shadowColor=Color.new(168,184,184) @commands=@stock end def itemsInPocket return @stock[self.index][1]>0 end def itemCount return @stock.length end def drawItem(index,count,rect) pbSetSystemFont(self.contents) if @starting rect=drawCursor(index,rect) if index!=@stock.length-1 maxitems=@stock[index][2] items=@stock[index][1] pbDrawTextPositions(self.contents,[ [_INTL("{1}/{2}",items,maxitems),rect.width,rect.y,1,self.baseColor,self.shadowColor] ]) end pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height, @stock[index][0],self.baseColor,self.shadowColor) end end class Window_ItemListBase < Window_DrawableCommand def initialize(stock,x,y,width,height,viewport=nil) @stock=stock @itemUsing=AnimatedBitmap.new("Graphics/Pictures/secretBaseUsing") super(x,y,width,height,viewport) @baseColor=Color.new(88,88,80) @shadowColor=Color.new(168,184,184) end def itemCount return @stock.length end def item return self.index==itemCount-1 ? 0 : @stock[self.index][0] end def drawItem(index,count,rect) textpos=[] rect=drawCursor(index,rect) ypos=rect.y if index==itemCount-1 itemname=@stock[index] else itemname=baseItemName(@stock[index][0]) if @stock[index][1] pbCopyBitmap(self.contents,@itemUsing.bitmap,rect.width-16,ypos+6) end end textpos.push([itemname,rect.x,ypos+2,false,self.baseColor,self.shadowColor]) pbDrawTextPositions(self.contents,textpos) end end class DecorateItem def initialize commands=[] ret=-1 for i in 0...BASEBAGPOCKETS.length pocket=BASEBAGPOCKETS[i] items=$PokemonGlobal.basePocketLength(i) commands.push([pocket[0],items,pocket[1]]) end commands.push(["Cancel",-1,-1]) cmdwindow=Window_PocketsList.new(commands,0,0,Graphics.width/2,DEFAULTSCREENHEIGHT) cmdwindow.z=99999 cmdwindow.visible=true cmdwindow.index=0 loop do Graphics.update Input.update cmdwindow.update if Input.trigger?(Input::C) break if cmdwindow.index==cmdwindow.stock.length-1 if !cmdwindow.itemsInPocket cmdwindow.visible=false Kernel.pbMessage("There are no decorations.") cmdwindow.visible=true else ret=cmdwindow.index break end elsif Input.trigger?(Input::B) ret=-1 break end end cmdwindow.dispose itemList(ret) if ret!=-1 end def pbPrepareWindow(window) window.visible=true window.letterbyletter=false end def itemList(pocket) ret=-1 pocket=$PokemonGlobal.getBasePocket(pocket) items=[] for i in 0...pocket.length items.push(pocket[i]) end items.push("Cancel") cmdwindow=Window_ItemListBase.new(items,0,0,Graphics.width/2,DEFAULTSCREENHEIGHT) cmdwindow.index=0 cmdwindow.refresh oldindex=cmdwindow.index desc=cmdwindow.item>0 ? baseItemDesc(cmdwindow.item) : "Go back to the previous menu." descwindow=Window_AdvancedTextPokemon.new(desc) pbPrepareWindow(descwindow) descwindow.visible=true descwindow.x=Graphics.width/2 descwindow.y=DEFAULTSCREENHEIGHT-128 descwindow.width=Graphics.width/2 descwindow.height=128 descwindow.baseColor=Color.new(88,88,80) descwindow.shadowColor=Color.new(168,184,184) loop do Graphics.update Input.update cmdwindow.update if oldindex!=cmdwindow.index desc=cmdwindow.item>0 ? baseItemDesc(cmdwindow.item) : "Go back to the previous menu." descwindow.text=desc oldindex=cmdwindow.index end if Input.trigger?(Input::C) if cmdwindow.index==cmdwindow.itemCount-1 ret=-1 break else if pocket[cmdwindow.index][1] descwindow.visible=false cmdwindow.visible=false Kernel.pbMessage("This is in use already.") descwindow.visible=true cmdwindow.visible=true else ret=cmdwindow.index break end end elsif Input.trigger?(Input::B) ret=-1 break end end cmdwindow.dispose descwindow.dispose if ret!=-1 startDecoration(pocket[ret],ret) else initialize end end def startDecoration(item,itemnum) scene=PokemonDecoration.new scene.pbStartScene scene.pbCreatePlaceItem(item) placed=scene.pbPlaceItem(item) if placed item[1]=true end initialize end end class TossItem def initialize commands=[] ret=-1 for i in 0...BASEBAGPOCKETS.length pocket=BASEBAGPOCKETS[i] items=$PokemonGlobal.basePocketLength(i) commands.push([pocket[0],items,pocket[1]]) end commands.push(["Cancel",-1,-1]) cmdwindow=Window_PocketsList.new(commands,0,0,Graphics.width/2,DEFAULTSCREENHEIGHT) cmdwindow.z=99999 cmdwindow.visible=true cmdwindow.index=0 loop do Graphics.update Input.update cmdwindow.update if Input.trigger?(Input::C) break if cmdwindow.index==cmdwindow.stock.length-1 if !cmdwindow.itemsInPocket cmdwindow.visible=false Kernel.pbMessage("There are no decorations.") cmdwindow.visible=true else ret=cmdwindow.index break end elsif Input.trigger?(Input::B) ret=-1 break end end cmdwindow.dispose itemList(ret) if ret!=-1 end def pbPrepareWindow(window) window.visible=true window.letterbyletter=false end def itemList(pocketr) ret=-1 pocket=$PokemonGlobal.getBasePocket(pocketr) items=[] for i in 0...pocket.length items.push(pocket[i]) end items.push("Cancel") cmdwindow=Window_ItemListBase.new(items,0,0,Graphics.width/2,DEFAULTSCREENHEIGHT) cmdwindow.index=0 cmdwindow.refresh oldindex=cmdwindow.index desc=cmdwindow.item>0 ? baseItemDesc(cmdwindow.item) : "Go back to the previous menu." descwindow=Window_AdvancedTextPokemon.new(desc) pbPrepareWindow(descwindow) descwindow.visible=true descwindow.x=Graphics.width/2 descwindow.y=DEFAULTSCREENHEIGHT-128 descwindow.width=Graphics.width/2 descwindow.height=128 descwindow.baseColor=Color.new(88,88,80) descwindow.shadowColor=Color.new(168,184,184) loop do Graphics.update Input.update cmdwindow.update if oldindex!=cmdwindow.index desc=cmdwindow.item>0 ? baseItemDesc(cmdwindow.item) : "Go back to the previous menu." descwindow.text=desc oldindex=cmdwindow.index end if Input.trigger?(Input::C) if cmdwindow.index==cmdwindow.itemCount-1 ret=-1 break else if pocket[cmdwindow.index][1] descwindow.visible=false cmdwindow.visible=false Kernel.pbMessage("This decoration is in use.\nIt can't be thrown away.") descwindow.visible=true cmdwindow.visible=true else ret=cmdwindow.index break end end elsif Input.trigger?(Input::B) ret=-1 break end end cmdwindow.dispose descwindow.dispose if ret!=-1 # Item selected n=$PokemonGlobal.getBasePocket(pocketr) itemname=baseItemName(n[ret][0]) if Kernel.pbConfirmMessage(_INTL("This {1} will be discarded\nIs that okay?",itemname)) n.delete_at(ret) Kernel.pbMessage("The decoration item was thrown away.") itemList(pocketr) else initialize # Back end else # Back initialize end end end class DecorationPC def shouldShow? return true end def access loop do command=Kernel.pbShowCommandsWithHelp(nil, [_INTL("Decorate"), _INTL("Put away"), _INTL("Toss"), _INTL("Cancel")], [_INTL("Put out the selected decoration item."), _INTL("Store the chosen decoration in the PC."), _INTL("Throw away unwanted decorations."), _INTL("Go back to the previous menu.")],-1 ) if command==0 scene=DecorateItem.new elsif command==1 scene=PokemonDecoration.new scene.pbStartScene scene.pbCreatePutAway scene.pbPutAway elsif command==2 scebe=TossItem.new else break end end end end class PackUpPC def shouldShow? return true end def packup(eventid) #$scene.disposeSpritesets # Reload the original map data $game_map.backToOriginal # Back all items to pc for p in 0...BASEBAGPOCKETS.length pocket=$PokemonGlobal.getBasePocket(p) for i in 0...pocket.length pocket[i][1]=false end end #$scene.createSpritesets $PokemonGlobal.installed=false $PokemonGlobal.mybaseid=-1 $PokemonGlobal.mybaselocation=-1 $game_self_switches[[$game_map.map_id,eventid,"B"]]=true $game_map.need_refresh=true end def access Kernel.pbMessage(_INTL("All decorations and furniture in your Secret Base will be returned to your PC.\1")) if !Kernel.pbConfirmMessage( _INTL("Is that okay?")) return false end return true end end def pbSecretBasePC copyMapData Kernel.pbMessage(_INTL("\\se[accesspc]{1} booted up the PC.",$Trainer.name)) loop do commands=["Decoration","Pack up","Exit"] command=Kernel.pbMessage(_INTL("What would you like to do?"), commands,commands.length) if command==0 scene=DecorationPC.new scene.access elsif command==1 scene=PackUpPC.new if scene.access scene.packup(get_character(0).id) break end else pbSEPlay("computerclose") break end end copyMapData end #=============================================================================== # Mart system #=============================================================================== class Window_BaseMart < Window_DrawableCommand def initialize(stock,x,y,width,height,viewport=nil) @stock=stock super(x,y,width,height,viewport) @baseColor=Color.new(88,88,80) @shadowColor=Color.new(168,184,184) self.windowskin=nil end def itemCount return @stock.length+1 end def item return self.index>=@stock.length ? 0 : @stock[self.index] end def getDisplayPrice(id) price=baseItemCost(id) return _ISPRINTF("${1:d}",price) end def drawItem(index,count,rect) textpos=[] rect=drawCursor(index,rect) ypos=rect.y if index==count-1 textpos.push([_INTL("CANCEL"),rect.x,ypos+2,false, self.baseColor,self.shadowColor]) else item=@stock[index] itemname=baseItemName(item) qty=getDisplayPrice(item) sizeQty=self.contents.text_size(qty).width xQty=rect.x+rect.width-sizeQty-2-16 textpos.push([itemname,rect.x,ypos+2,false,self.baseColor,self.shadowColor]) textpos.push([qty,xQty,ypos+2,false,self.baseColor,self.shadowColor]) end pbDrawTextPositions(self.contents,textpos) end end def pbBottomLeftLinesScreen(window,lines,width=nil) window.x=0 window.width=width ? width : Graphics.width window.height=(window.borderY rescue 32)+lines*32 window.y=DEFAULTSCREENHEIGHT-window.height end class SecretBaseMartScene def update pbUpdateSpriteHash(@sprites) end def pbPrepareWindow(window) window.visible=true window.letterbyletter=false end def initialize(stock) pbScrollMap(6,3,5) @adapter=$PokemonBag ? PokemonMartAdapter.new : RpgxpMartAdapter.new @viewport=Viewport.new(0,0,Graphics.width,DEFAULTSCREENHEIGHT) @viewport.z=99999 @sprites={} @sprites["background"]=IconSprite.new(0,0,@viewport) @sprites["background"].setBitmap("Graphics/Pictures/secretMartScreen") @sprites["itemwindow"]=Window_BaseMart.new(stock, Graphics.width-266,12,278,DEFAULTSCREENHEIGHT-32) @sprites["itemwindow"].viewport=@viewport @sprites["itemwindow"].index=0 @sprites["itemwindow"].refresh @sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("") pbPrepareWindow(@sprites["itemtextwindow"]) @sprites["itemtextwindow"].y=DEFAULTSCREENHEIGHT-112 @sprites["itemtextwindow"].width=Graphics.width/2 @sprites["itemtextwindow"].height=128 @sprites["itemtextwindow"].baseColor=Color.new(248,248,248) @sprites["itemtextwindow"].shadowColor=Color.new(0,0,0) @sprites["itemtextwindow"].visible=true @sprites["itemtextwindow"].viewport=@viewport @sprites["itemtextwindow"].windowskin=nil @sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["helpwindow"]) @sprites["helpwindow"].visible=false @sprites["helpwindow"].viewport=@viewport pbBottomLeftLinesScreen(@sprites["helpwindow"],1) @sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") pbPrepareWindow(@sprites["moneywindow"]) @sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin") @sprites["moneywindow"].visible=true @sprites["moneywindow"].viewport=@viewport @sprites["moneywindow"].x=0 @sprites["moneywindow"].y=0 @sprites["moneywindow"].width=190 @sprites["moneywindow"].height=96 @sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].shadowColor=Color.new(168,184,184) pbDeactivateWindows(@sprites) pbUpdate end def pbUpdate @sprites["itemicon"].dispose if @sprites["itemicon"] iconbitmap=(@sprites["itemwindow"].item==0) ? BitmapCache.load_bitmap("Graphics/Icons/itemBack") : getBaseItemBitmap(@sprites["itemwindow"].item) @sprites["itemicon"]=PictureWindow.new(iconbitmap) @sprites["itemicon"].viewport=@viewport @sprites["itemicon"].x=4 @sprites["itemicon"].y=278-@sprites["itemicon"].height @sprites["moneywindow"].text=_INTL("Money:\n<r>${1}",@adapter.getMoney()) @sprites["itemtextwindow"].text=(@sprites["itemwindow"].item==0) ? _INTL("Quit shopping.") : baseItemDesc(@sprites["itemwindow"].item) end def pbEndScene pbDisposeSpriteHash(@sprites) pbScrollMap(4,3,5) pbWait(1) end def pbDisplayPaused(msg) cw=@sprites["helpwindow"] cw.letterbyletter=true cw.text=msg pbBottomLeftLinesScreen(cw,2) cw.visible=true i=0 pbPlayDecisionSE() loop do Graphics.update Input.update wasbusy=cw.busy? self.update if !cw.busy? && wasbusy pbUpdate end if Input.trigger?(Input::C) && cw.resume && !cw.busy? @sprites["helpwindow"].visible=false return end end end def pbChooseBuyItem oldindex=@sprites["itemwindow"].index pbActivateWindow(@sprites,"itemwindow"){ loop do if oldindex!=@sprites["itemwindow"].index pbUpdate oldindex=@sprites["itemwindow"].index end Graphics.update Input.update self.update if Input.trigger?(Input::C) return @sprites["itemwindow"].item elsif Input.trigger?(Input::B) return 0 end end } end end class SecretBaseMartScreen def initialize(scene) @scene=scene @adapter=$PokemonBag ? PokemonMartAdapter.new : RpgxpMartAdapter.new end def pbDisplayPaused(msg) return @scene.pbDisplayPaused(msg) end def pbBuyScreen loop do @item=@scene.pbChooseBuyItem if @item>0 itemname=baseItemName(@item) price=baseItemCost(@item) if @adapter.getMoney()<price pbDisplayPaused(_INTL("You don't have enough money.")) next else itempocket=baseItemPocket(@item) if $PokemonGlobal.basePocketLength(itempocket)<getMaxSecretBagPocket(itempocket) @adapter.setMoney(@adapter.getMoney()-price) pbDisplayPaused(_INTL("Here you are!\r\nThank you!")) pbGetBaseItem(@item) next else pbDisplayPaused(_INTL("The space for {1} is full.",itemname)) next end end else break end end @scene.pbEndScene end end def pbSecretBaseMart(stock,speech=nil) for i in 0...stock.length if stock[i].is_a?(String) stock[i]=getBaseItemByName(stock[i]) end end stock.compact! commands=[] cmdBuy=-1 cmdSell=-1 cmdQuit=-1 commands[cmdBuy=commands.length]=_INTL("BUY") commands[cmdQuit=commands.length]=_INTL("QUIT") cmd=Kernel.pbMessage( speech ? speech : _INTL("Welcome!\r\nHow may I serve you?"), commands,cmdQuit+1) loop do if cmdBuy>=0 && cmd==cmdBuy sscene=SecretBaseMartScene.new(stock) sscreen=SecretBaseMartScreen.new(sscene) sscreen.pbBuyScreen else Kernel.pbMessage(_INTL("Please come again!")) break end cmd=Kernel.pbMessage( _INTL("Is there anything else I can help you with?"),commands,cmdQuit+1) end end #=============================================================================== # Creating secret bases #=============================================================================== def pbTeletransport(id,x,y) Kernel.pbCancelVehicles $game_temp.player_new_map_id=id $game_temp.player_new_x=x $game_temp.player_new_y=y $game_temp.player_new_direction=8 $scene.transfer_player $game_map.autoplay $game_map.refresh end def pbPackup(id) for p in 0...BASEBAGPOCKETS.length pocket=$PokemonGlobal.getBasePocket(p) for i in 0...pocket.length pocket[i][1]=false end end $PokemonGlobal.installed=false $PokemonGlobal.mybaseid=-1 $PokemonGlobal.mybaselocation=-1 if $PokemonGlobal.baseinfo && $PokemonGlobal.baseinfo[id] $PokemonGlobal.baseinfo[id].clear $PokemonGlobal.baseinfo[id]=nil end end def pbNewSecretBase newBaseId=get_character(0).name.gsub("SECRETBASE", "").to_i movefinder=Kernel.pbCheckMove(BASEMOVENEEDED) if movefinder && $PokemonGlobal.getBaseId>=0 Kernel.pbMessage("You may only make one secret base.\1") mapname=pbGetMapNameFromId($PokemonGlobal.getBaseLocation) movename=PBMoves.getName(getID(PBMoves,BASEMOVENEEDED)) if Kernel.pbConfirmMessage(_INTL("Would you like to move from the secret base near {1}?",mapname)) Kernel.pbMessage(_INTL("All decorations and furniture in your secret base will be returned to your PC.\1")) if Kernel.pbConfirmMessage(_INTL("Is that okay?")) pbPackup($PokemonGlobal.getBaseId) $PokemonGlobal.mybaseid=-1 $PokemonGlobal.mybaselocation=-1 $game_map.reloadEventsForBase pbFlash(Color.new(0,0,0),16) pbWait(18) Kernel.pbMessage(_INTL("Moving complete.\1")) if Kernel.pbConfirmMessage(_INTL("Would you like to use {1}?",movename)) speciesname=!movefinder ? $Trainer.name : movefinder.name Kernel.pbMessage(_INTL("{1} used {2}!",speciesname,movename)) pbHiddenMoveAnimation(movefinder) $PokemonGlobal.mybaseid=newBaseId $PokemonGlobal.mybaselocation=$game_map.map_id $PokemonGlobal.outdoordata=[$game_map.map_id,$game_player.x,$game_player.y] $game_map.reloadEventsForBase return true end end end elsif movefinder movename=PBMoves.getName(getID(PBMoves,BASEMOVENEEDED)) if Kernel.pbConfirmMessage(_INTL("Would you like to use {1}?",movename)) speciesname=!movefinder ? $Trainer.name : movefinder.name Kernel.pbMessage(_INTL("{1} used {2}!",speciesname,movename)) pbHiddenMoveAnimation(movefinder) $PokemonGlobal.mybaseid=newBaseId $PokemonGlobal.mybaselocation=$game_map.map_id $PokemonGlobal.outdoordata=[$game_map.map_id,$game_player.x,$game_player.y] $game_map.reloadEventsForBase return true end end return false end def getDoorPos(map) map=load_data(sprintf("Data/Map%03d.%s", map,$RPGVX ? "rvdata" : "rxdata")) map.events.each do |i, event| return [event.x, event.y] if event.name=="DOOR" end return [0,0] end def pbInstallingBase if Kernel.pbConfirmMessage("Want to make your secret base here?") $PokemonGlobal.installed=true return true else $PokemonGlobal.installed=false $PokemonGlobal.mybaseid=-1 $PokemonGlobal.mybaselocation=-1 return false end end class Game_Map def reloadEventsForBase for i in @events.keys if @events[i] && @events[i].rEvent && @events[i].rEvent.name.include?("SECRETBASE") mapid=@events[i].rEvent.name.gsub("SECRETBASE", "").to_i $game_self_switches[[@map_id,@events[i].id,"A"]]=false if mapid==$PokemonGlobal.getBaseId $game_self_switches[[@map_id,@events[i].id,"A"]]=true end @need_refresh=true end end end def searchForMyBase for i in @map.events.keys if @map.events[i].name.include?("SECRETBASE") mapid=@map.events[i].name.gsub("SECRETBASE", "").to_i @events[i].rEvent=@map.events[i].clone $game_self_switches[[@map_id,@events[i].id,"A"]]=false if mapid==$PokemonGlobal.getBaseId $game_self_switches[[@map_id,@events[i].id,"A"]]=true end elsif @map.events[i].name.include?("BASEPC") # Disable self switches $game_self_switches[[@map_id,@events[i].id,"B"]]=false $game_self_switches[[@map_id,@events[i].id,"A"]]=false # Make available pcs if it's your base if $game_map.map_id==$PokemonGlobal.getBaseId && $PokemonGlobal.installed $game_self_switches[[@map_id,@events[i].id,"A"]]=true end end end @need_refresh=true end end #=============================================================================== # ■ Functions for users #=============================================================================== # - pbMakeNumericTileset(TILESETNAME) # This will save in your project's folder the tileset you've selected # with a numeric patron. #=============================================================================== def pbGetBaseItem(itemid) item=itemid if itemid.is_a?(String) item=getBaseItemByName(itemid) end itempocket=baseItemPocket(item) if $PokemonGlobal.basePocketLength(itempocket)<getMaxSecretBagPocket(itempocket) $PokemonGlobal.baseItemBag[itempocket].push([item,false]) return true end return false end def pbMakeNumericTileset(name) file=sprintf("Graphics/Tilesets/"+name) return if !FileTest.image_exist?(file) tileset=BitmapCache.load_bitmap(file) numericSet=tileset.clone pbSetSystemFont(numericSet) numericSet.font.size=21 for width in 0...numericSet.width/32 for height in 0...numericSet.height/32 number=(width+(height*8)).to_s nsize=numericSet.text_size(number) text=[[ number,(width+1)*32-16,height*32,2,Color.new(255,0,0),Color.new(0,0,0) ]] pbDrawTextPositions(numericSet,text) end end numericSet.export(sprintf(name+"_numeric")) Kernel.pbMessage(_INTL("Saved in game's folder: {1}_numeric",name)) end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
work.png.txt
3 hours ago | 475.67 KB
Disable Drag and Drop Image Improved Plugin i...
PHP | 4 hours ago | 1.31 KB
SAVE
5 hours ago | 0.06 KB
ZELAH
5 hours ago | 0.01 KB
z66is_archive.zip.txt
6 hours ago | 1.53 KB
programming
7 hours ago | 0.03 KB
thought
7 hours ago | 0.14 KB
STORY ENGINE
7 hours ago | 1.14 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!