• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Trading Items for Items

Sporefame19

Amateur Cartographer
30
Posts
11
Years
  • I was wondering if there is a way to trade items for items? I am asking since i would like to incorporate a berry trading shop in my game. It would hopefully have a shop like interface. Thanks in advance. :)
     

    Yusshin

    ♪ Yggdrasil ♪
    2,414
    Posts
    14
    Years
  • I know of a simple way to do it. You simply conditional-branch it and take away what's being traded and giving the item you want using the Kernel scripts.

    That wouldn't work for mass-trading, though. Just a handful, maybe, without it feeling cluttered or messy.
     

    Sporefame19

    Amateur Cartographer
    30
    Posts
    11
    Years
  • I was hoping for a large shop. XD Oh well. I guess I'll just make multiple traders. Thanks for the help. I didn't think I would get a reply so fast. :D
     

    Black Eternity

    Lord of Eternity
    57
    Posts
    11
    Years
    • Seen Jun 30, 2016
    I was intrigued by this, so I took a little time to try and script something myself, and here is what I like.
    This is nothing fancy like the mart, I based some of this from "Kurt"

    First I added a new script section PokemonBerryTrading
    and added this script:
    Code:
    def pbBerryTrader(id)
      if id==0
        pbChooseItemFromList(
          _INTL("I am looking for these kinds of berries, can you spare some?"),16,
          :CHERIBERRY,:CHESTOBERRY,:PECHABERRY)
      elsif id==1
        pbChooseItemFromList(
          _INTL("I am looking for these kinds of berries, can you spare some?"),16,
          :RAWSTBERRY,:ASPEARBERRY,:LEPPABERRY)
      elsif id==2
        pbChooseItemFromList(
          _INTL("I am looking for these kinds of berries, can you spare some?"),16,
          :ORANBERRY,:PERSIMBERRY,:LUMBERRY)
      elsif id==3
        pbChooseItemFromList(
          _INTL("I am looking for these kinds of berries, can you spare some?"),16,
          :SITRUSBERRY,:FIGYTBERRY,:WIKIBERRY)
      end
    end
    
    def pbBerryAmount
      max=$PokemonBag.pbQuantity(pbGet(16))
      params=ChooseNumberParams.new
      params.setMaxDigits(2)
      params.setRange(1,max)
      params.setInitialValue(1)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
        _INTL("How many would you like to trade?"),params)
      pbSet(17,qty)
    end
    
    def pbBerryPick(id)
      if id==0
        pbChooseItemFromList2(_INTL("Which berry would you like?"),18,
          :MAGOBERRY,:AGUAVBERRY,:IAPAPABERRY)
      elsif id==1
        pbChooseItemFromList2(_INTL("Which berry would you like?"),18,
          :RAZZBERRY,:BLUKBERRY,:NANABBERRY)
      elsif id==2
        pbChooseItemFromList2(_INTL("Which berry would you like?"),18,
          :WEPEARBERRY,:PINAPBERRY,:POMEGBERRY)
      end
    end
    
    def pbBerryTrade
      $PokemonBag.pbDeleteItem(pbGet(16),pbGet(17))
      Kernel.pbReceiveItem(pbGet(18),pbGet(17))
    end

    Now you can see for pbBerryTrader(id) it is just choosing an item from a list that the player has. in this case there are 3, you can add more.

    The main reason I decided to put this in the scripts was because the default RMXP script editor only allows a certain amount of lines to be added. This also allows for easy Event editing, as everything is predefined in this script.

    pbBerryAmount is just for choosing an amount to be traded.
    pbBerryPick is another list, that the player can choose from to decide what berry they will be receiving.
    pbBerryTrade is what will delete, and add chosen berries.

    And last, you will notice that there is pbChooseItemFromList2
    This is pretty much a copy of the original, except, it does not check if the player has it, otherwise you would be trading your own berries.......

    So in PokemonItems section, add this after the original:
    Code:
    def pbChooseItemFromList2(message,variable,*args)
      commands=[]
      itemid=[]
      for item in args
        if hasConst?(PBItems,item)
          id=getConst(PBItems,item)
          commands.push(PBItems.getName(id))
          itemid.push(id)
        end
      end
      if commands.length==0
        $game_variables[variable]=0
        return -1
      end
      commands.push(_INTL("Cancel"))
      itemid.push(0)
      ret=Kernel.pbMessage(message,commands,-1)
      if ret<0 || ret>=commands.length-1
        $game_variables[variable]=-1
        return -1
      else
        $game_variables[variable]=itemid[ret]
        return itemid[ret]
      end
    end

    You can easily add new Berry Traders, by adding in more "id"s like this:
    Code:
      elsif id==[COLOR="Blue"]4[/COLOR]
        pbChooseItemFromList(
          _INTL("I am looking for these kinds of berries, can you spare some?"),16,
          :[COLOR="red"]ITEM[/COLOR],:[COLOR="red"]ITEM[/COLOR],:[COLOR="Red"]ITEM[/COLOR])

    And also more pbBerryPick by using the same method, allowing for infinite trade possibilities.

    To set up the event, just call the 4 scripts like so:
    Code:
    script: pbBerryTrader(ID)
    script: pbBerryPick(ID)
    script: pbBerryAmount
    script: pbBerryTrade

    And that is all for my version. Hope it helps at least a little.

    If you want to change what variables the script uses its pretty easy, mine are set like:
    0016: BerryTraded
    0017: BerryAmount
    0018: BerryRecieved

    just change all 16's, 17's, and 18's to whatever you desire.
     
    Last edited:

    Sporefame19

    Amateur Cartographer
    30
    Posts
    11
    Years
  • Thank you so much Black! I'll Credit you and Kurt. This helps so much :) I'm glad you took the time to do this. Anyway, thanks again! :D
     

    Black Eternity

    Lord of Eternity
    57
    Posts
    11
    Years
    • Seen Jun 30, 2016
    Thank you so much Black! I'll Credit you and Kurt. This helps so much :) I'm glad you took the time to do this. Anyway, thanks again! :D

    Thank you. :) anyways, i meant "Kurt" as in the NPC that does the apricorn thing lol.
    EDIT: The script is not really complete, the player can still get the berry received even if they have no berries. you will need to add a way to check if they do.
     
    Last edited:

    Sporefame19

    Amateur Cartographer
    30
    Posts
    11
    Years
  • Thank you. :) anyways, i meant "Kurt" as in the NPC that does the apricorn thing lol.
    EDIT: The script is not really complete, the player can still get the berry received even if they have no berries. you will need to add a way to check if they do.

    Hahaha. XD Sorry for the confusion. I'll find a way to do the checking.
     

    Black Eternity

    Lord of Eternity
    57
    Posts
    11
    Years
    • Seen Jun 30, 2016
    Doing the check is as simple as doing some conditionals in the event.

    Use this as a reference.
    Not sure if setting 0018 to zero is needed.
    Trading Items for Items
     
    Back
    Top