< >
Hello, guest! Please log in or register.

The PokéCommunity

Go Back     The PokéCommunity Forums > Create & Discover > Game Development > Scripts & Tutorials Essentials script Wonder Trade (offline) v1.2

Notices

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply Post Reply
 
Thread Tools
  #1    
Old October 2nd, 2014 (12:21 AM). Edited November 13th, 2014 by Black Eternity.
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
To copy this script without any errors, go to Thread Tools and select, Show Printable Version.

Spoiler:

Code:
=begin
*** Wonder Trade Script by Black Eternity ***
This script is to mimic Wonder Trade from an offline perspective.
THERE IS NO ONLINE CAPABILITIES OF THIS SCRIPT,
ALL CALCULATIONS ARE DONE INTERNALLY.

To call the script like normal and have ALL Pokemon trade-able, use the following.
    pbWondertrade(1,[],[])

Black listed Pokemon are to be added to the Exceptions arrays.
  Except is the list of pokemon the player is forbidden to trade.
    Here the player cannot trade any of the following.
      pbWonderTrade(1,[:PIKACHU,:SQUIRTLE,:CHARMANDER,;BULBASAUR],[])
    
  Except2 is the list of pokemon the player is forbidden to receive.
    Here the player cannot receive any of the following.
      pbWonderTrade(1,[],[:MEWTWO,;MEW,;DEOXYS])



The first parameter is the minimum allowed Level of the Pokemon to be traded.
For example, you can not trade a Pokemon through Wonder Trade unless its level
is greater than or equal to specified level.

    pbWonderTrade(40,[:SQUIRTLE,:CHARMANDER,:BULBASAUR],[:MEWTWO,:MEW,:DEOXYS])
    *** Only pokemon over level 40 can be traded, you cannot trade starters.
    *** You cannot receive these legendaries.
    
The fourth parameter, which has recently replaced mej71's "hardobtain"
is called "rare", this parameter developed also by mej71, will use
the Pokemon's rareness and filter the results depending on its values.

** Rareness is turned on by default, if you wish to disable it, call the
    function accordingly.
    
    pbWonderTrade(10,[:SQUIRTLE],[:CHARMANDER,:BULBASAUR],false)
    ** Only Pokemon over level 10, cannot trade Squirtle, cannot
    ** recieve Charmander or Bulbasaur, Rareness disabled.

It is up to you to use it how you wish, credits will be appreciated.
=end

# List of Randomly selected Trainer Names
# These are just names taken from a generator, add custom or change to
# whatever you desire.
RandTrainerNames=[
"Clarence",
"James",
"Keith",
"Matthew",
"Jeremy",
"Louis",
"Albert",
"Emily",
"Aaron",
"Frances",
"Steve",
"Joan",
"Dorothy",
"Jeffrey",
"Alice",
"Sara",
"David",
"Anne",
"Shirley",
"Henry",
"Carolyn",
"Christopher",
"Christina",
"Ronald",
"Randy",
"Nancy",
"Virginia",
"Donna",
"William",
"Jacqueline",
"Catherine",
"Jesse",
"Roger",
"Denise",
"Ashley",
"Maria",
"Todd",
"Helen",
"Teresa",
"Fred",
"Annie",
"Rachel",
"Kathleen",
"Marie",
"Scott",
"Phillip",
"Craig",
"Diane",
"Beverly",
"Lisa",
"Mildred",
"Lois",
"Douglas",
"Deborah",
"Phyllis",
"Melissa",
"Laura",
"Stephanie",
"Ernest",
"Evelyn",
"Irene",
"Brandon",
"Jean",
"Sandra",
"Linda",
"Raymond",
"Kathryn",
"Harry",
"Gary",
"Katherine",
"Theresa",
"Howard",
"Stephen",
"Russell",
"Louisel",
"Bobby",
"Susan",
"Martin",
"Harold",
"Andrea",
"Sharon",
"Juan",
"Rose",
"Lori",
"Dorist",
"Joseph",
"Charles",
"Donald",
"Arthur",
"Janice",
"Jack",
"Wanda",
"Ralph",
"Christine",
"Betty",
"Julia",
"Michelle",
"Kevin",
"James",
"Michael",
"Kathy"
]

# List of randomly selected Pokemon Nicknames
# These are just names taken from a generator, add custom or change to
# whatever you desire.
RandPokeNick=[
"Delev",
"Aelask",
"Arik",
"Thach",
"Kroaal",
"Gez",
"Adaetyra",
"Aroan",
"Jaua",
"Cu",
"Kes",
"Ini",
"Rairim",
"Chior",
"Zeam",
"Kaimyn",
"Trou",
"Anaz",
"Taelah",
"Tok",
"Foalyua",
"Kransela",
"Jendal",
"Cimor",
"Birev",
"Iseaz",
"Mim",
"Arily",
"Susk",
"Naer",
"Ennn",
"Mea",
"Anaz",
"Xoken",
"Binn",
"Paed",
"Dandara",
"Cova",
"Aeran",
"Gom",
"Bancath",
"Elish",
"Lex",
"Kiz",
"Tullas",
"Idaithael",
"Nonc",
"Krairoa",
"Talanen",
"Chyar",
"Drakinoa",
"Koul",
"Cikr",
"Doukl",
"Pydae",
"Sokl",
"Galas",
"Voav",
"Ade",
"Jeal",
"Drym",
"Beary",
"Cam",
"Elyd",
"Alaev",
"Zissal",
"Neteth",
"Teaes",
"Famah",
"Jylyath",
"Dod",
"Idorroa",
"Sicha",
"Ca",
"Deal",
"Kro",
"Ziz",
"Thom",
"Dam",
"Souk",
"Sandren",
"Sytr",
"Drumri",
"Isi",
"Basri",
"Jell",
"Araphorn",
"Kaesselai",
"Resh",
"Fizarus"
]


def pbWonderTrade(lvl,except=[],except2=[],rare=true)
	for i in 0...except.length # Gets ID of pokemon in exception array
		except[i]=getID(PBSpecies,except[i]) if !except[i].is_a?(Integer)
	end
	for i in 0...except2.length # Gets ID of pokemon in exception array
		except2[i]=getID(PBSpecies,except2[i]) if !except2[i].is_a?(Integer)
	end
	except+=[]
	chosen=pbChoosePokemon(1,2, # Choose eligable pokemon
	proc {
	|poke| !poke.egg? && !(poke.isShadow?) && # No Eggs, No Shadow Pokemon
	(poke.level>=lvl) && !(except.include?(poke.species)) # None under "lvl", no exceptions.
	})
	# The following excecption fields are for hardcoding the blacklisted pokemon
	# without adding them in the events.
	#except+=[]
	except2+=[]
	if pbGet(1)>=0
		species=0
		while (species==0) # Loop Start
			species=rand(PBSpecies.maxValue)+1
			# Redo the loop if the species is an exception.
			species=0 if except2.include?(species)
			# species=0 if (except.include?(species) && except2.include?(species))
			# use this above line instead if you wish to neither receive pokemon that YOU
			# cannot trade.
      if rare==true #turn on rareness
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,species,16)
        rareness=dexdata.fgetb # Get rareness from dexdata file
        dexdata.close 
        species=0 if rand(255)>=rareness
      end
		end
		tname=RandTrainerNames[rand(RandTrainerNames.size)] # Randomizes Trainer Names
		pname=RandPokeNick[rand(RandPokeNick.size)] # Randomizes Pokemon Nicknames
		pbStartTrade(pbGet(1),species,pname,tname) # Starts the trade
	else
		return -1
	end
end
This has not been tested extensively, I only made sure that the basics are functional.
If you happen to find any bugs, errors, or nonsense, please comment your experience below,
and I will do the best to correct/resolve/comment back.


v1.2 Changelog 11/13/14
Replaced mej71 hardobtain with his own rareness check
Added parameter for rareness

v1.1 Changelog
Fixed typos
Hard Obtain function added by mej71
Small bug fixes by mej71

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote

Relevant Advertising!

  #2    
Old October 2nd, 2014 (4:31 AM).
baaabuuu baaabuuu is offline
 
Join Date: Jun 2014
Gender: Male
Posts: 14
It is currently bugging up for me
i . gyazo . com/bee70bcb035be5f810e258000d562570 is a picture of my event.

Spoiler:

Code:
Exception: RuntimeError
Message: Script error within event 1, map 105 (MAP105):
Exception: NoMethodError
Message: (eval):1:in `pbExecuteScript'undefined method `pbWondertrade' for #<Interpreter:0xaf13b48>
***Full script:
pbWondertrade(1,[],[])

Interpreter:243:in `pbExecuteScript'
Interpreter:1600:in `eval'
Interpreter:243:in `pbExecuteScript'
Interpreter:1600:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `update'
Scene_Map:101:in `loop'

Interpreter:276:in `pbExecuteScript'
Interpreter:1600:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `update'
Scene_Map:101:in `loop'
Scene_Map:114:in `update'
Scene_Map:68:in `main'
Exception: RuntimeError
Message: Script error within event 1, map 105 (MAP105):
Exception: SyntaxError
Message: (eval):1:in `pbExecuteScript'compile error
(eval):1: syntax error
pbWonderTrade(1,[:PIKACHU,:SQUIRTLE,:CHARMANDER,;BULBASAUR],[])
Reply With Quote
  #3    
Old October 2nd, 2014 (8:55 AM).
mej71's Avatar
mej71 mej71 is offline
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
Posts: 968
Quote:
Originally Posted by baaabuuu View Post
It is currently bugging up for me
i . gyazo . com/bee70bcb035be5f810e258000d562570 is a picture of my event.

Spoiler:

Code:
Exception: RuntimeError
Message: Script error within event 1, map 105 (MAP105):
Exception: NoMethodError
Message: (eval):1:in `pbExecuteScript'undefined method `pbWondertrade' for #<Interpreter:0xaf13b48>
***Full script:
pbWondertrade(1,[],[])

Interpreter:243:in `pbExecuteScript'
Interpreter:1600:in `eval'
Interpreter:243:in `pbExecuteScript'
Interpreter:1600:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `update'
Scene_Map:101:in `loop'

Interpreter:276:in `pbExecuteScript'
Interpreter:1600:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `update'
Scene_Map:101:in `loop'
Scene_Map:114:in `update'
Scene_Map:68:in `main'
Exception: RuntimeError
Message: Script error within event 1, map 105 (MAP105):
Exception: SyntaxError
Message: (eval):1:in `pbExecuteScript'compile error
(eval):1: syntax error
pbWonderTrade(1,[:PIKACHU,:SQUIRTLE,:CHARMANDER,;BULBASAUR],[])
*pbWonderTrade

capitalization is important
Reply With Quote
  #4    
Old October 2nd, 2014 (10:51 PM).
mej71's Avatar
mej71 mej71 is offline
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
Posts: 968
Quote:
Originally Posted by Black Eternity View Post
Spoiler:


This has not been tested extensively, I only made sure that the basics are functional.
If you happen to find any bugs, errors, or nonsense, please comment your experience below,
and I will do the best to correct/resolve/comment back.

Quick note, your example
Code:
pbWonderTrade(40,[:SQUIRTLE,:CHARMANDER,;BULBASAUR],[:MEWTWO,;MEW,;DEOXYS])
is incorrect. The red highlighted parts should be colons instead of semicolons. It will return a syntax error when used, and if it were to somehow pass that it would still error out because getID(PBSpecies,;MEWTWO) is incorrect syntax.

Another suggestion has nothing to do with your script, and is just a preference of mine, but something I noticed while using it. In the trade scene (PokemonTrading , lines 153), def pbTrade should be changed to this

Code:
def pbTrade
    pbBGMStop()
    pbPlayCry(@pokemon)
    speciesname1=PBSpecies.getName(@pokemon.species)
    speciesname2=PBSpecies.getName(@pokemon2.species)
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _ISPRINTF("{1:s}\r\nID: {2:05d}   OT: {3:s}\\wtnp[0]",
       @pokemon.name,@pokemon.publicID,@pokemon.ot))
    Kernel.pbMessageWaitForInput(@sprites["msgwindow"],100,true)
    pbPlayDecisionSE()
    pbScene1
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("For {1}'s {2},\r\n{3} sends {4}.\1",@trader1,speciesname1,@trader2,speciesname2))
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("{1} bids farewell to {2} the {3}.",@trader2,@pokemon2.name,speciesname2))
    pbScene2
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _ISPRINTF("{1:s}\r\nID: {2:05d}   OT: {3:s}\1",
       @pokemon2.name,@pokemon2.publicID,@pokemon2.ot))
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("Take good care of {1}.",@pokemon2.name))
  end
Changed parts are in red. This is purely a preference, but it makes trades seem more personal for the other trainer.

This is a nice script btw.
Reply With Quote
  #5    
Old October 3rd, 2014 (12:03 AM). Edited October 3rd, 2014 by Black Eternity.
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
Hi mej71, thank you for noticing the small typos I have made,
I will correct them.

And I do enjoy your suggestion for pbTrade.

If you have any more suggestions for the script please let me
know as I am always open to constructive criticism.
Thanks for testing it out.

I plan on adding more features in the near future, but those will wait until I sort out all
possible bugs in the basic version.

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #6    
Old October 3rd, 2014 (8:30 PM). Edited October 3rd, 2014 by mej71.
mej71's Avatar
mej71 mej71 is offline
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
Posts: 968
Quote:
Originally Posted by Black Eternity View Post
Hi mej71, thank you for noticing the small typos I have made,
I will correct them.

And I do enjoy your suggestion for pbTrade.

If you have any more suggestions for the script please let me
know as I am always open to constructive criticism.
Thanks for testing it out.

I plan on adding more features in the near future, but those will wait until I sort out all
possible bugs in the basic version.
I added a small feature which allows you to hardcode pokemon that should be more difficult to obtain but possible. Without blacklisting any pokemon, there is about a 7% chance you will get a legendary. With this you can reduce that chance to 1% (you can reduce it farther with some minor tweaking) if you want anything to be obtainable, but not too easy. Highlighted additions in red

Spoiler:
Code:
=begin
*** Wonder Trade Script by Black Eternity ***
This script is to mimic Wonder Trade from an offline perspective.
THERE IS NO ONLINE CAPABILITIES OF THIS SCRIPT,
ALL CALCULATIONS ARE DONE INTERNALLY.

To call the script like normal and have ALL Pokemon trade-able, use the following.
    pbWondertrade(1,[],[])

Black listed Pokemon are to be added to the Exceptions arrays.
  Except is the list of pokemon the player is forbidden to trade.
    Here the player cannot trade any of the following.
      pbWonderTrade(1,[:PIKACHU,:SQUIRTLE,:CHARMANDER,;BULBASAUR],[])
    
  Except2 is the list of pokemon the player is forbidden to receive.
    Here the player cannot receive any of the following.
      pbWonderTrade(1,[],[:MEWTWO,;MEW,;DEOXYS])



The first parameter is the minimum allowed Level of the Pokemon to be traded.
For example, you can not trade a Pokemon through Wonder Trade unless its level
is greater than or equal to specified level.

    pbWonderTrade(40,[:SQUIRTLE,:CHARMANDER,:BULBASAUR],[:MEWTWO,:MEW,:DEOXYS])
    *** Only pokemon over level 40 can be traded, you cannot trade starters.
    *** You cannot receive these legendaries.

It is up to you to use it how you wish, credits will be appreciated.
=end

# List of Randomly selected Trainer Names
# These are just names taken from a generator, add custom or change to
# whatever you desire.
RandTrainerNames=[
"Clarence",
"James",
"Keith",
"Matthew",
"Jeremy",
"Louis",
"Albert",
"Emily",
"Aaron",
"Frances",
"Steve",
"Joan",
"Dorothy",
"Jeffrey",
"Alice",
"Sara",
"David",
"Anne",
"Shirley",
"Henry",
"Carolyn",
"Christopher",
"Christina",
"Ronald",
"Randy",
"Nancy",
"Virginia",
"Donna",
"William",
"Jacqueline",
"Catherine",
"Jesse",
"Roger",
"Denise",
"Ashley",
"Maria",
"Todd",
"Helen",
"Teresa",
"Fred",
"Annie",
"Rachel",
"Kathleen",
"Marie",
"Scott",
"Phillip",
"Craig",
"Diane",
"Beverly",
"Lisa",
"Mildred",
"Lois",
"Douglas",
"Deborah",
"Phyllis",
"Melissa",
"Laura",
"Stephanie",
"Ernest",
"Evelyn",
"Irene",
"Brandon",
"Jean",
"Sandra",
"Linda",
"Raymond",
"Kathryn",
"Harry",
"Gary",
"Katherine",
"Theresa",
"Howard",
"Stephen",
"Russell",
"Louisel",
"Bobby",
"Susan",
"Martin",
"Harold",
"Andrea",
"Sharon",
"Juan",
"Rose",
"Lori",
"Dorist",
"Joseph",
"Charles",
"Donald",
"Arthur",
"Janice",
"Jack",
"Wanda",
"Ralph",
"Christine",
"Betty",
"Julia",
"Michelle",
"Kevin",
"James",
"Michael",
"Kathy"
]

# List of randomly selected Pokemon Nicknames
# These are just names taken from a generator, add custom or change to
# whatever you desire.
RandPokeNick=[
"Delev",
"Aelask",
"Arik",
"Thach",
"Kroaal",
"Gez",
"Adaetyra",
"Aroan",
"Jaua",
"Cu",
"Kes",
"Ini",
"Rairim",
"Chior",
"Zeam",
"Kaimyn",
"Trou",
"Anaz",
"Taelah",
"Tok",
"Foalyua",
"Kransela",
"Jendal",
"Cimor",
"Birev",
"Iseaz",
"Mim",
"Arily",
"Susk",
"Naer",
"Ennn",
"Mea",
"Anaz",
"Xoken",
"Binn",
"Paed",
"Dandara",
"Cova",
"Aeran",
"Gom",
"Bancath",
"Elish",
"Lex",
"Kiz",
"Tullas",
"Idaithael",
"Nonc",
"Krairoa",
"Talanen",
"Chyar",
"Drakinoa",
"Koul",
"Cikr",
"Doukl",
"Pydae",
"Sokl",
"Galas",
"Voav",
"Ade",
"Jeal",
"Drym",
"Beary",
"Cam",
"Elyd",
"Alaev",
"Zissal",
"Neteth",
"Teaes",
"Famah",
"Jylyath",
"Dod",
"Idorroa",
"Sicha",
"Ca",
"Deal",
"Kro",
"Ziz",
"Thom",
"Dam",
"Souk",
"Sandren",
"Sytr",
"Drumri",
"Isi",
"Basri",
"Jell",
"Araphorn",
"Kaesselai",
"Resh",
"Fizarus"
]
#Pokemon that will have a smaller chance of being given (legendaries, etc)
HardToObtain=[
:JIRACHI,
:DEOXYS,
:GIRATINA,
:MEW
]

def pbWonderTrade(lvl,except,except2=[],hardobtainpercent=15)
        for i in 0...except.length # Gets ID of pokemon in exception array
                except[i]=getID(PBSpecies,except[i]) if !except[i].is_a?(Integer)
        end
        for i in 0...except2.length # Gets ID of pokemon in exception array
                except2[i]=getID(PBSpecies,except2[i]) if !except2[i].is_a?(Integer)
        end
        hardobtain=[]
        for i in 0...HardToObtain.size
          hardobtain.push(getID(PBSpecies,HardToObtain[i])) if !(HardToObtain[i].is_a?(Integer))
          hardobtainpush(HardToObtain[i]) if HardToObtain[i].is_a?(Integer)
        end
        except+=[]
        chosen=pbChoosePokemon(1,2, # Choose eligable pokemon
        proc {
  |poke| !poke.egg? && !(poke.isShadow?) && # No Eggs, No Shadow Pokemon
  (poke.level>=lvl) && !(except.include?(poke.species)) # None under "lvl", no exceptions.
  })
  # The following excecption fields are for hardcoding the blacklisted pokemon
  # without adding them in the events.
  #except+=[]
  except2+=[]
  if pbGet(1)>=0
    species=0
      while (species==0) # Loop Start
        species=rand(PBSpecies.maxValue)+1
        # Redo the loop if the species is an exception.
        species=0 if except2.include?(species)
        # species=0 if (except.include?(species) && except2.include?(species))
        # use this above line instead if you wish to neither receive pokemon that YOU
        # cannot trade.
        if hardobtain.include?(species) #if species is in the hard to obtain array
          species=0 if rand(100)>hardobtainpercent #set to 15 percent chance of 
          #continuing with that species, user can change when calling method
        end  
      end
    tname=RandTrainerNames[rand(RandTrainerNames.size)] # Randomizes Trainer Names
    pname=RandPokeNick[rand(RandPokeNick.size)] # Randomizes Pokemon Nicknames
    pbStartTrade(pbGet(1),species,pname,tname) # Starts the trade
  else
    return -1
  end
end


You'll also notice I moved the except+=[] line (highlighted blue). Where it was, if you were to hardcode any exception pokemon it wouldn't have any effect, because it was occurring after you picked your pokemon.

Edit: Highlighted in green is something to make the exception of what you're trading work (disallowing your player to pick his Charmander or whatever).
Reply With Quote
  #7    
Old October 3rd, 2014 (9:00 PM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
Quote:
Originally Posted by mej71 View Post
I added a small feature which allows you to hardcode pokemon that should be more difficult to obtain but possible. Without blacklisting any pokemon, there is about a 7% chance you will get a legendary. With this you can reduce that chance to 1% (you can reduce it farther with some minor tweaking) if you want anything to be obtainable, but not too easy. Highlighted additions in red

Spoiler:
Code:
=begin
*** Wonder Trade Script by Black Eternity ***
This script is to mimic Wonder Trade from an offline perspective.
THERE IS NO ONLINE CAPABILITIES OF THIS SCRIPT,
ALL CALCULATIONS ARE DONE INTERNALLY.

To call the script like normal and have ALL Pokemon trade-able, use the following.
    pbWondertrade(1,[],[])

Black listed Pokemon are to be added to the Exceptions arrays.
  Except is the list of pokemon the player is forbidden to trade.
    Here the player cannot trade any of the following.
      pbWonderTrade(1,[:PIKACHU,:SQUIRTLE,:CHARMANDER,;BULBASAUR],[])
    
  Except2 is the list of pokemon the player is forbidden to receive.
    Here the player cannot receive any of the following.
      pbWonderTrade(1,[],[:MEWTWO,;MEW,;DEOXYS])



The first parameter is the minimum allowed Level of the Pokemon to be traded.
For example, you can not trade a Pokemon through Wonder Trade unless its level
is greater than or equal to specified level.

    pbWonderTrade(40,[:SQUIRTLE,:CHARMANDER,:BULBASAUR],[:MEWTWO,:MEW,:DEOXYS])
    *** Only pokemon over level 40 can be traded, you cannot trade starters.
    *** You cannot receive these legendaries.

It is up to you to use it how you wish, credits will be appreciated.
=end

# List of Randomly selected Trainer Names
# These are just names taken from a generator, add custom or change to
# whatever you desire.
RandTrainerNames=[
"Clarence",
"James",
"Keith",
"Matthew",
"Jeremy",
"Louis",
"Albert",
"Emily",
"Aaron",
"Frances",
"Steve",
"Joan",
"Dorothy",
"Jeffrey",
"Alice",
"Sara",
"David",
"Anne",
"Shirley",
"Henry",
"Carolyn",
"Christopher",
"Christina",
"Ronald",
"Randy",
"Nancy",
"Virginia",
"Donna",
"William",
"Jacqueline",
"Catherine",
"Jesse",
"Roger",
"Denise",
"Ashley",
"Maria",
"Todd",
"Helen",
"Teresa",
"Fred",
"Annie",
"Rachel",
"Kathleen",
"Marie",
"Scott",
"Phillip",
"Craig",
"Diane",
"Beverly",
"Lisa",
"Mildred",
"Lois",
"Douglas",
"Deborah",
"Phyllis",
"Melissa",
"Laura",
"Stephanie",
"Ernest",
"Evelyn",
"Irene",
"Brandon",
"Jean",
"Sandra",
"Linda",
"Raymond",
"Kathryn",
"Harry",
"Gary",
"Katherine",
"Theresa",
"Howard",
"Stephen",
"Russell",
"Louisel",
"Bobby",
"Susan",
"Martin",
"Harold",
"Andrea",
"Sharon",
"Juan",
"Rose",
"Lori",
"Dorist",
"Joseph",
"Charles",
"Donald",
"Arthur",
"Janice",
"Jack",
"Wanda",
"Ralph",
"Christine",
"Betty",
"Julia",
"Michelle",
"Kevin",
"James",
"Michael",
"Kathy"
]

# List of randomly selected Pokemon Nicknames
# These are just names taken from a generator, add custom or change to
# whatever you desire.
RandPokeNick=[
"Delev",
"Aelask",
"Arik",
"Thach",
"Kroaal",
"Gez",
"Adaetyra",
"Aroan",
"Jaua",
"Cu",
"Kes",
"Ini",
"Rairim",
"Chior",
"Zeam",
"Kaimyn",
"Trou",
"Anaz",
"Taelah",
"Tok",
"Foalyua",
"Kransela",
"Jendal",
"Cimor",
"Birev",
"Iseaz",
"Mim",
"Arily",
"Susk",
"Naer",
"Ennn",
"Mea",
"Anaz",
"Xoken",
"Binn",
"Paed",
"Dandara",
"Cova",
"Aeran",
"Gom",
"Bancath",
"Elish",
"Lex",
"Kiz",
"Tullas",
"Idaithael",
"Nonc",
"Krairoa",
"Talanen",
"Chyar",
"Drakinoa",
"Koul",
"Cikr",
"Doukl",
"Pydae",
"Sokl",
"Galas",
"Voav",
"Ade",
"Jeal",
"Drym",
"Beary",
"Cam",
"Elyd",
"Alaev",
"Zissal",
"Neteth",
"Teaes",
"Famah",
"Jylyath",
"Dod",
"Idorroa",
"Sicha",
"Ca",
"Deal",
"Kro",
"Ziz",
"Thom",
"Dam",
"Souk",
"Sandren",
"Sytr",
"Drumri",
"Isi",
"Basri",
"Jell",
"Araphorn",
"Kaesselai",
"Resh",
"Fizarus"
]
#Pokemon that will have a smaller chance of being given (legendaries, etc)
HardToObtain=[
:JIRACHI,
:DEOXYS,
:GIRATINA,
:MEW
]

def pbWonderTrade(lvl,except,except2=[],hardobtainpercent=15)
        for i in 0...except.length # Gets ID of pokemon in exception array
                except[i]=getID(PBSpecies,except[i]) if !except[i].is_a?(Integer)
        end
        for i in 0...except2.length # Gets ID of pokemon in exception array
                except2[i]=getID(PBSpecies,except2[i]) if !except2[i].is_a?(Integer)
        end
        hardobtain=[]
        for i in 0...HardToObtain.size
          hardobtain.push(getID(PBSpecies,HardToObtain[i])) if !(HardToObtain[i].is_a?(Integer))
          hardobtainpush(HardToObtain[i]) if HardToObtain[i].is_a?(Integer)
        end
        except+=[]
        chosen=pbChoosePokemon(1,2, # Choose eligable pokemon
        proc {
  |poke| !poke.egg? && !(poke.isShadow?) && # No Eggs, No Shadow Pokemon
  (poke.level>=lvl) && !(except.include?(poke.species)) # None under "lvl", no exceptions.
  })
  # The following excecption fields are for hardcoding the blacklisted pokemon
  # without adding them in the events.
  #except+=[]
  except2+=[]
  if pbGet(1)>=0
    species=0
      while (species==0) # Loop Start
        species=rand(PBSpecies.maxValue)+1
        # Redo the loop if the species is an exception.
        species=0 if except2.include?(species)
        # species=0 if (except.include?(species) && except2.include?(species))
        # use this above line instead if you wish to neither receive pokemon that YOU
        # cannot trade.
        if hardobtain.include?(species) #if species is in the hard to obtain array
          species=0 if rand(100)>hardobtainpercent #set to 15 percent chance of 
          #continuing with that species, user can change when calling method
        end  
      end
    tname=RandTrainerNames[rand(RandTrainerNames.size)] # Randomizes Trainer Names
    pname=RandPokeNick[rand(RandPokeNick.size)] # Randomizes Pokemon Nicknames
    pbStartTrade(pbGet(1),species,pname,tname) # Starts the trade
  else
    return -1
  end
end


You'll also notice I moved the except+=[] line (highlighted blue). Where it was, if you were to hardcode any exception pokemon it wouldn't have any effect, because it was occurring after you picked your pokemon.

Edit: Highlighted in green is something to make the exception of what you're trading work (disallowing your player to pick his Charmander or whatever).
Good catch, didnt pay attention to except=[] location.
And nice addition to hardobtain, I added your updates to the OP.
Thanks

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #8    
Old October 4th, 2014 (3:21 AM).
Maruno's Avatar
Maruno Maruno is offline
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Posts: 5,095
Couldn't you have used the capture rates to decide how common each species is? And then just implement a blacklist for the Pokémon you don't want at all to be in there?
Reply With Quote
  #9    
Old October 14th, 2014 (7:21 PM).
Zeak6464's Avatar
Zeak6464 Zeak6464 is offline
The Cold Guy
 
Join Date: Mar 2013
Location: USA
Gender: Male
Nature: Calm
Posts: 445
Send a message via Skype™ to Zeak6464
So the only time i get an error is when i used it in PokeGear.

After i received a pokemon it throws out an error at me ...
PC Events Attended:


PC Events Won:
Reply With Quote
  #10    
Old October 15th, 2014 (1:49 PM).
DL Kurosh's Avatar
DL Kurosh DL Kurosh is offline
 
Join Date: May 2014
Posts: 95
Quote:
Originally Posted by Zeak6464 View Post
So the only time i get an error is when i used it in PokeGear.

After i received a pokemon it throws out an error at me ...
Which error do you get? We can't help you without more information =P
Reply With Quote
  #11    
Old October 15th, 2014 (3:48 PM).
Zeak6464's Avatar
Zeak6464 Zeak6464 is offline
The Cold Guy
 
Join Date: Mar 2013
Location: USA
Gender: Male
Nature: Calm
Posts: 445
Send a message via Skype™ to Zeak6464
Quote:
Originally Posted by DL Kurosh View Post
Which error do you get? We can't help you without more information =P
PC Events Attended:


PC Events Won:
Reply With Quote
  #12    
Old October 16th, 2014 (6:15 PM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
This error is not pertaining to the WonderTrade script, it looks more like there is an
issue with however you are calling the a scene with PokeGear.

I have been testing this extensively over the past couple days.
I call the function by using a simple mouse click in my own "PokeGear"

It should also be noted, that WonderTrade is not its own "scene"
you can call this code using any event by just "pbWonderTrade(1,[],[],15)"
or any other parameters you desire.

Code:
if $mouse.pbMouseLeftClick?(@sprites["wonder"])
	pbWonderTrade(40,[],[])
end

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #13    
Old October 18th, 2014 (6:34 AM).
Zeak6464's Avatar
Zeak6464 Zeak6464 is offline
The Cold Guy
 
Join Date: Mar 2013
Location: USA
Gender: Male
Nature: Calm
Posts: 445
Send a message via Skype™ to Zeak6464
Yeah i fixed it
i had "Scene =" so i just removed that and it worked in the PokeGear
PC Events Attended:


PC Events Won:
Reply With Quote
  #14    
Old October 20th, 2014 (2:14 AM).
xXDizeXx's Avatar
xXDizeXx xXDizeXx is offline
 
Join Date: Jul 2014
Location: germany
Gender: Male
Posts: 12
I just get an error when i start the game

Script "wondertrade" line 260yntaxError occurred.

when i delete this line i get the same at the line 284

any ideas?
Reply With Quote
  #15    
Old October 20th, 2014 (3:59 AM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
Quote:
Originally Posted by xXDizeXx View Post
I just get an error when i start the game

Script "wondertrade" line 260yntaxError occurred.

when i delete this line i get the same at the line 284

any ideas?
Make sure you copy the script from printable.
Click "Thread Tools" > "Show Printable Version"
If that does not solve any error, post back and let me know.

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #16    
Old October 20th, 2014 (7:05 AM).
xXDizeXx's Avatar
xXDizeXx xXDizeXx is offline
 
Join Date: Jul 2014
Location: germany
Gender: Male
Posts: 12
now it works thanks a lot
Reply With Quote
  #17    
Old October 20th, 2014 (9:02 AM).
Bowlstir's Avatar
Bowlstir Bowlstir is offline
Media Arts and Game Development
 
Join Date: Apr 2008
Location: USA
Gender: Male
Nature: Adamant
Posts: 189
Thanks, it works perfectly.

The only thing I had to do was to change the calling script. (Capitalized the 'T' in Trade)


Reply With Quote
  #18    
Old October 21st, 2014 (1:10 PM). Edited October 21st, 2014 by LevelXGER.
LevelXGER LevelXGER is offline
 
Join Date: Oct 2014
Posts: 1
Hello Hello,
thanks for this script. Its working fine for me.

But ive 2-3 Questions...

First:
Is it possible to open the save screen inside the script so it cannot get abused?
I tried it before and after but still there is a way to bug it out to just reset the game and get a different pokemon.

Second:
pbWonderTrade(40,[],[],1)

The 2nd [] define the Pokemon you are not able to get. Got this.

But my Script is now like 1 million words long because i added all Pokemon names from 152 till end. Is there an easier way? Like somewhere in the Script itself to give an Option about the range of Pokemon to give? For example: 1-151
I know i can hardcode them but i would like to have it different from script to script


Third:

I am not sure if this is possible because i didnt found a "WORKING" way for this but may we can choose the levelrange?

Like you give a level 50 Pokemon... ok got this point... but you get always a same level pokemon back. Why not make it like a range? 50-60 or 1-100.

I am not sure if i can manipulate the Pokemon before the trade but i will defintly try it.


Hope for a nice answer.
Sincerely
Reply With Quote
  #19    
Old October 22nd, 2014 (1:25 AM). Edited October 22nd, 2014 by Black Eternity.
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
1. Go to Pokemon Trading and make the following changes:
Copy Red Highlights and delete, Paste to Blue highlighted spot.
Add Green Highlighted.
Code:
def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0)
  myPokemon=$Trainer.party[pokemonIndex]
  opponent=PokeBattle_Trainer.new(trainerName,trainerGender)
  opponent.setForeignID($Trainer)
  yourPokemon=nil
  if newpoke.is_a?(PokeBattle_Pokemon)
    newpoke.trainerID=opponent.id
    newpoke.ot=opponent.name
    newpoke.otgender=opponent.gender
    newpoke.language=opponent.language
    yourPokemon=newpoke
  else
    yourPokemon=PokeBattle_Pokemon.new(newpoke,myPokemon.level,opponent)
  end
  $Trainer.party[pokemonIndex]=yourPokemon
  yourPokemon.name=nickname
  yourPokemon.resetMoves
  yourPokemon.obtainMode=2 # traded
  $Trainer.seen[yourPokemon.species]=true
  $Trainer.owned[yourPokemon.species]=true
  pbSeenForm(yourPokemon)
  pbSave
  pbFadeOutInWithMusic(99999){
    evo=PokemonTradeScene.new
    evo.pbStartScreen(myPokemon,yourPokemon,$Trainer.name,opponent.name)
    evo.pbTrade
    evo.pbEndScreen
  }
  $Trainer.party[pokemonIndex]=yourPokemon
end
2. add another conditional to the loop process. I have used.
This allows only Gen 2 pokemon.
Code:
if species<=151 || species>=252
        species=0
end
This does not allow 1ST or 3RD Gen pokemon.
Code:
if (species<=151) || (species>=252 && species<=386)
        species=0
end
3. You would need to modify the Trade script.
Specifically here:
Code:
if newpoke.is_a?(PokeBattle_Pokemon)
    newpoke.trainerID=opponent.id
    newpoke.ot=opponent.name
    newpoke.otgender=opponent.gender
    newpoke.language=opponent.language
    yourPokemon=newpoke
  else
    yourPokemon=PokeBattle_Pokemon.new(newpoke,myPokemon.level,opponent)
  end

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #20    
Old November 5th, 2014 (9:33 AM).
mej71's Avatar
mej71 mej71 is offline
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
Posts: 968
I replaced the loop to include Maruno's suggestion of using rareness for the species
Code:
while (species==0) # Loop Start
        species=rand(PBSpecies.maxValue)+1
        # Redo the loop if the species is an exception.
        species=0 if except2.include?(species)
        # species=0 if (except.include?(species) && except2.include?(species))
        # use this above line instead if you wish to neither receive pokemon that YOU
        # cannot trade.
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,species,16)
        rareness=dexdata.fgetb # Get rareness from dexdata file
        dexdata.close 
        species=0 if rand(255)>=rareness
      end
I took out all the stuff I added before, this is much cleaner.
Reply With Quote
  #21    
Old November 13th, 2014 (1:30 AM).
Black Eternity's Avatar
Black Eternity Black Eternity is offline
Lord of Eternity
 
Join Date: Sep 2012
Age: 23
Gender: Male
Posts: 59
Thank you mej71 for your contributions, the main post has been updated with your features.

[Pokemon Essentials Scripts]
Banking System: Here
Berry Trading System: Here
Reply With Quote
  #22    
Old November 20th, 2014 (1:16 PM).
TheGuyver TheGuyver is offline
 
Join Date: Jun 2014
Gender: Male
Nature: Adamant
Posts: 23
Send a message via Skype™ to TheGuyver
This script is fantastic, it runs with the RMX-OS kit just fine too. Thanks a lot for your hard work.
Reply With Quote
  #23    
Old November 22nd, 2014 (3:31 PM).
Badhaas's Avatar
Badhaas Badhaas is offline
 
Join Date: Jul 2013
Gender: Male
Posts: 116
The script looks great and works nicely.

A while back I had a similar idea and wrote the idea behind an algorithm of how to pick the received Pokémon (based on what you would likely receive if it worked just like the actual wonder trade). I never got to coding it though. If you're interested I could post it here or pm it to you.

View my profile page for scripts/tutorials made by me, even ones which aren't posted yet.
Currently working on a demo for Tales from the Pokémon World (based on the World of Pokémon project)
Reply With Quote
  #24    
Old July 25th, 2015 (7:24 PM).
Pokemoner1 Pokemoner1 is offline
 
Join Date: Jul 2015
Posts: 10
Quote:
Originally Posted by Zeak6464 View Post
yust so you know thats another script totally different so i dont know why is it affecting in that moment is an error with PokemonBattle_Pokemon you can check it reading the 2nd line sorry for responding until now
Reply With Quote
  #25    
Old July 26th, 2015 (6:05 AM).
Zeak6464's Avatar
Zeak6464 Zeak6464 is offline
The Cold Guy
 
Join Date: Mar 2013
Location: USA
Gender: Male
Nature: Calm
Posts: 445
Send a message via Skype™ to Zeak6464
Quote:
Originally Posted by Pokemoner1 View Post
yust so you know thats another script totally different so i dont know why is it affecting in that moment is an error with PokemonBattle_Pokemon you can check it reading the 2nd line sorry for responding until now
i fixed this a while ago ...

"Yeah i fixed it
i had "Scene =" so i just removed that and it worked in the PokeGear"
PC Events Attended:


PC Events Won:
Reply With Quote
Reply Post Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


  All times are GMT -8. The time now is 8:25 PM.


Contact Us Archive Privacy Statement Terms of Service Top