• The Eevee Expo Game Jam #10 has concluded, congratulations to all participants! Now it's time for the judges to play through the games, and you can play along to vote who deserves the community choice spotlight.
    You can check out the submitted games here!
    Play through the games and provide some feedback to the devs while you're at it!
  • Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Pokémon Mart

Pokémon Mart 1.0

Pokémon Essentials Version
v18.1 ➖
What is this?
A script for creating a Mart for buying Pokémon in the same style as the regular one. It is intended to be plug'n'play and pretty easy to use. This was born from a discussion on Discord and was made with a intention to show how easy it is to create a interface for buying (and selling) anything using any currency. This was made in under 30 mins and should be a good example on how to expand the regular mart feature. I have no plans on expanding this any further.

What it looks like?
af38bc5b10ffff5a7a888dd5ffade977.gif


Installation

Paste the script below above main:
Ruby:
Expand Collapse Copy
#===============================================================================
#  Pokémon Mart
#    by JV
# ----------------
#  Provides an interface and backend for buying Pokémon in the same
#  style as the regular mart.
#
#  To use, simply create a script call from an event:
#  'pbPokemonCreaturesMart([[species,price,level],...])'
#
#  Example: 'pbPokemonCreaturesMart([[:PIKACHU,12000,10],[:ABRA,5000,12]])'
#
#  Enjoy the script, and make sure to give credit!
#-------------------------------------------------------------------------------

PluginManager.register({
  :name => "JV's Pokémon Mart",
  :version => "1.0",
  :credits => "JV",
  :link => "https://reliccastle.com/resources/464/"
})

#-------------------------------------------------------------------------------

def pbPokemonCreaturesMart(stock,speech=nil)
  for i in 0...stock.length
    stock[i][0] = getID(PBSpecies,stock[i][0])
    if !stock[i][0] || stock[i][0]==0
      stock[i] = nil
    end
  end
  stock.compact!
  commands = []
  cmdBuy  = -1
  cmdSell = -1
  cmdQuit = -1
  commands[cmdBuy = commands.length]  = _INTL("Buy")
  commands[cmdQuit = commands.length] = _INTL("Quit")
  cmd = pbMessage(
     speech ? speech : _INTL("Welcome! How may I serve you?"),
     commands,cmdQuit+1)
  loop do
    if cmdBuy>=0 && cmd==cmdBuy
      scene = PokemonCreaturesMart_Scene.new
      screen = PokemonCreaturesMartScreen.new(scene,stock)
      screen.pbBuyScreen
    else
      pbMessage(_INTL("Please come again!"))
      break
    end
    cmd = pbMessage(_INTL("Is there anything else I can help you with?"),
       commands,cmdQuit+1)
  end
  $game_temp.clear_mart_prices
end

class PokemonCreaturesMartAdapter
  def initialize(stock)
    @stock = stock
  end

  def getMoney
    return $Trainer.money
  end

  def getMoneyString
    return pbGetGoldString
  end

  def setMoney(value)
    $Trainer.money=value
  end

  def getInventory
    return $Trainer.party
  end

  def getDisplayName(item)
    itemname = PBSpecies.getName(item)
    for i in @stock
      level = i[2] if i[0] == item
    end
    return "#{itemname} (Lv. #{level})"
  end

  def getName(item)
    return PBSpecies.getName(item)
  end

  def getDescription(item)
    echoln(item)
    return pbGetMessage(MessageTypes::Entries,item)
  end

  def getItemIcon(item)
    return nil if !item
    file = pbCheckPokemonIconFiles([item,nil,nil,nil,nil],nil)
    return AnimatedBitmap.new(file).deanimate
  end

  def getItemIconRect(_item)
    return Rect.new(0,0,64,64)
  end

  def getQuantity(item)
    return nil
  end

  def showQuantity?(item)
    return false
  end

  def getPrice(item,selling=false)
    for i in @stock
      return i[1] if i[0] == item
    end
    return 10000
  end

  def getDisplayPrice(item,selling=false)
    price = getPrice(item,selling).to_s_formatted
    return _INTL("$ {1}",price)
  end

  def canSell?(item)
    return false
  end

  def addItem(item)
    level = 5
    for i in @stock
      level = i[2] if i[0] == item && i[2]
    end
    return pbAddPokemon(item,level)
  end

  def removeItem(item)
    return nil
  end
end

class PokemonCreaturesMartScreen < PokemonMartScreen
  def initialize(scene,stock)
    @scene=scene
    @stock=[]
    @adapter=PokemonCreaturesMartAdapter.new(stock)
    for i in stock
      @stock.push(i.first)
    end
  end

  def pbBuyScreen
    @scene.pbStartBuyScene(@stock,@adapter)
    item=0
    loop do
      item=@scene.pbChooseBuyItem
      quantity=1
      break if item==0
      itemname=@adapter.getDisplayName(item)
      price=@adapter.getPrice(item)
      if @adapter.getMoney<price
        pbDisplayPaused(_INTL("You don't have enough money."))
        next
      end
      if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
          itemname,price.to_s_formatted))
        next
      end
      unless pbBoxesFull?
        @adapter.setMoney(@adapter.getMoney-price)
        pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
        @adapter.addItem(item)
      else
        pbDisplayPaused(_INTL("You have no more room in the Storage."))
      end
    end
    @scene.pbEndBuyScene
  end
end

class PokemonCreaturesMart_Scene < PokemonMart_Scene
  def pbRefresh
    if @subscene
      @subscene.pbRefresh
    else
      itemwindow=@sprites["itemwindow"]
      @sprites["icon"].species=itemwindow.item
      @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
         "<fs=24>#{@adapter.getDescription(itemwindow.item)}</fs>"
      itemwindow.refresh
    end
    @sprites["moneywindow"].text=_INTL("Money:\r\n<r>{1}",@adapter.getMoneyString)
  end

  def pbStartBuyOrSellScene(buying,stock,adapter)
    # Scroll right before showing screen
    pbScrollMap(6,5,5)
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @stock=stock
    @adapter=adapter
    @sprites={}
    @sprites["background"]=IconSprite.new(0,0,@viewport)
    @sprites["background"].setBitmap("Graphics/Pictures/martScreen")
    @sprites["icon"]=PokemonSpeciesIconSprite.new(0,@viewport)
    @sprites["icon"].x = 4
    @sprites["icon"].y = Graphics.height-90
    winAdapter=buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
    @sprites["itemwindow"]=Window_PokemonMart.new(stock,winAdapter,
       Graphics.width-316-16,12,330+16,Graphics.height-126)
    @sprites["itemwindow"].viewport=@viewport
    @sprites["itemwindow"].index=0
    @sprites["itemwindow"].refresh
    @sprites["itemtextwindow"]=Window_AdvancedTextPokemon.new("")
    pbPrepareWindow(@sprites["itemtextwindow"])
    @sprites["itemtextwindow"].x=64
    @sprites["itemtextwindow"].y=Graphics.height-96-16
    @sprites["itemtextwindow"].width=Graphics.width-64
    @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
    pbBottomLeftLines(@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)
    @buying=buying
    pbRefresh
    Graphics.frame_reset
  end

  def pbChooseBuyItem
    itemwindow=@sprites["itemwindow"]
    @sprites["helpwindow"].visible=false
    pbActivateWindow(@sprites,"itemwindow") {
      pbRefresh
      loop do
        Graphics.update
        Input.update
        olditem=itemwindow.item
        self.update
        if itemwindow.item!=olditem
          @sprites["icon"].species=itemwindow.item
          @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
          "<fs=24>#{@adapter.getDescription(itemwindow.item)}</fs>"
        end
        if Input.trigger?(Input::B)
          pbPlayCloseMenuSE
          return 0
        elsif Input.trigger?(Input::C)
          if itemwindow.index<@stock.length
            pbRefresh
            return @stock[itemwindow.index]
          else
            return 0
          end
        end
      end
    }
  end
end

How to use?

It's very similar to the regular mart script call. Simply, from an event, create a script call like this:
pbPokemonCreaturesMart([[species,price,level],...])

As you can see pbPokemonCreaturesMart receives an array of arrays containing the species, price and level of the pokémon to be available for purchase. Here is an actual example:
1602863669377.png


Enjoy!
Credits
This script is made by ~JV~. Please give credit!
Author
~JV~
Downloads
629
Views
5,542
First release
Last update

Ratings

4.75 star(s) 4 ratings

Latest reviews

Looks awesome, I dont think it works on v20.1 though
this worked perfectly for me as I'm using version 18.1. Thanks
I'd like to create a mart with random Pokemon eggs, does It work with egg as well?
~JV~
~JV~
As I said in the description, it should be pretty easy to adapt this to whatever is your need. For that, it should be a one line change in def addItem inside class PokemonCreaturesMartAdapter.
This is very good, this is exactly what i was looking for, however the font for the description of the pokemon is a little weird... Is there not a way to change it?
~JV~
~JV~
I know this is late, but check line 189 to change font size. I only reduced it so it fit the default graphic.
Back
Top