v19.1 Evolution Pokeball (script to check what ball the pokemon was caught with)

This thread pertains to v19.1 of Pokémon Essentials.

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
Hi all, Its my first time on the forums. I'm using 19.1

So I am attempting to create a new evoultion method that will evolve specific pokemon (trade pokemon) at the appropriate levels if they were caught with an Evolution Ball. I believe the script should check the ball type and if true check level and than the pokemon will evolve as normal. I've read the Wiki on evolution and believe that this is possible. I can check for a held item or an item to be used but it does not show how to check the ball type. If anyone has any ideas or knows what the script would look like I would really appreciate it. Thank you in advance.

The Evolution Ball during gameplay is an alternative for Trade Pokemon. EX: If your Geodude was caught using an Evolution Ball and leveled to a graveler like normal, once it was the appropriate level it would evolve to a Golem because it had an Evolution Ball, if it does not than nothing happens.

SOLUTION: Add both of the following scripts to Evolution in the Script Editor and an item to your item PBS named Evolution Ball. Both scripts will cause any pokemon caught with an evolution ball to evolve at level 30, the second script allows you to require trade items for evolution. In the bonus script at the bottom place it in Poke Ball Handlers in the Script Editor and add an item named Secret Ball to your Item PBS. I hope these scripts help others like they helped me and a special thanks for ThatWelshOne_ for all their help.

Trade Evolution and Evolution Ball Script (no item support):
GameData::Evolution.register({
  :id            => :LevelInBall,
  :level_up_proc => proc { |pkmn,|
    next pkmn.level >= 30 && pkmn.poke_ball == :EVOLUTIONBALL
  }
})

Evolutions = GOLEM,Trade,,GOLEM,LevelInBall

Trade Evolution and Evolution Ball Script (With Item Support):
GameData::Evolution.register({
  :id            => :LevelInBallItem,
  :parameter     => :Item,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= 30 && pkmn.poke_ball == :EVOLUTIONBALL && pkmn.item == parameter
  },
  :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
    next false if evo_species != new_species || !pkmn.hasItem?(parameter)
    pkmn.item = nil   # Item is now consumed
    next true
  }
})

Evolutions = STEELIX,TradeItem,METALCOAT,STEELIX,LevelInBallItem,METALCOAT

Make sure to alter the pokemon name and items above to whatever you need.

BONUS SCRIPT:

Poke Ball that unlocks the 1st hidden ability of the caught pokemon.:
BallHandlers::OnCatch.add(:SECRETBALL,proc { |ball,battle,pkmn|
  pkmn.ability_index = 2
  pkmn.ability       = nil
})

This poke ball has no effect on pokemon without hidden abilities.
 
Last edited:

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
class Pokemon objects have a poke_ball attribute that you can use to check what ball a Pokémon is in.
I think your new evolution method could look like this:
Ruby:
GameData::Evolution.register({
  :id            => :LevelInBall,
  :parameter     => Integer,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= parameter && pkmn.poke_ball == :EVOLUTIONBALL
  }
})
Replace :EVOLUTIONBALL with whatever the name is of your evolution ball.
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
I'm on my lunch break but was looking at the script. Whould this script go under ball modifiers or somewhere else? Also under the pokemon PB file what should I type for the evolution methods? I would still like to keep trade as an option and believe ,, can be used to allow both methods. Thanks again for the help so far.
 

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
All the other evolution bits are in the script called Evolution, about a third of the way down in the script editor (see image), so you could put it in there, maybe at the bottom of the script so it's easy to find again if you need to do so.
As for what to write in the PBS, good question! I think you would write Evolutions = GOLEM,Trade,,GOLEM,LevelInBall,28, replacing 28 with the level you want Graveler to evolve, for example. Pay attention to the empty section between Trade and the second GOLEM. You need to include that here.


Untitled.png
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
It works! I tested with the evolution ball and without. Thank you so much! If you wouldnt mind another scripting question I was wondering if it was possible to have a pokeball that sets a caught pokemon to having its hidden ability instead?

EDIT: I think I need an extra line for trade pokemon that require items to be held like Kings Rock, Metal Coat ect. Do you know the the line of script?
Would it be
Evolutions = STEELIX,Trade,,STEELIX,LevelInBall,28 and Item METALCOAT:
 
Last edited:

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
For your first question, you could go to the script called BallHandlers_PokeBallEffects (about halfway down in the script editor this time). At the bottom of the script, add this:
Ruby:
BallHandlers::OnCatch.add(:SECRETBALL,proc { |ball,battle,pkmn|
  pkmn.ability_index = 2
  pkmn.ability       = nil
})
This will set the caught Pokémon's ability to its first hidden ability. It's pretty basic since it doesn't consider other hidden abilities. I'm unsure what happens when a Pokémon doesn't have a hidden ability, like Koffing. It's worth you testing that.

For your second question, an evolution method can only have one free parameter, so there are three options as I see it:
1. Make it so that all trade evolutions evolve at the same level (fixed level, variable held item);
2. Make it so that all trade evolutions require the same held item (variable level, fixed held item);
3. Have an evolution method for every held item that induces evolution.

For the first option, your code might look like this:
Ruby:
GameData::Evolution.register({
  :id            => :LevelInBall,
  :parameter     => :Item,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= 28 && pkmn.poke_ball == :EVOLUTIONBALL && pkmn.item == parameter
  },
  :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
    next false if evo_species != new_species || !pkmn.hasItem?(parameter)
    pkmn.item = nil   # Item is now consumed
    next true
  }
})
Your PBS would then look like Evolutions = STEELIX,Trade,,STEELIX,LevelInBall,METALCOAT.

The second option might look like this:
Ruby:
GameData::Evolution.register({
  :id            => :LevelInBall,
  :parameter     => Integer,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= parameter && pkmn.poke_ball == :EVOLUTIONBALL && pkmn.item == :SUPERAMAZINGITEM
  },
  :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
    next false if evo_species != new_species || !pkmn.hasItem?(parameter)
    pkmn.item = nil   # Item is now consumed
    next true
  }
})
Your PBS would then look like Evolutions = STEELIX,Trade,,STEELIX,LevelInBall,28.

Here's an example for the third option:
Ruby:
GameData::Evolution.register({
  :id            => :LevelInBallMetalCoat,
  :parameter     => Integer,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= parameter && pkmn.poke_ball == :EVOLUTIONBALL && pkmn.item == :METALCOAT
  },
  :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
    next false if evo_species != new_species || !pkmn.hasItem?(parameter)
    pkmn.item = nil   # Item is now consumed
    next true
  }
})
Your PBS would then look like Evolutions = STEELIX,Trade,,STEELIX,LevelInBallMetalCoat,28. As I wrote above, you'd need one of these for every evolution held item. So, one for Metal Coat evolvers, one for King's Rock evolvers, one for Dragon Scale evolvers, etc.

It's up to you which approach you take.
I should also mention that I haven't tested any of this code so it might be wrong. I'll let you be the judge of that!
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
Thank you for your time I really appreciate it. I think I will use the 1st and set the level to 30 which I think should be fair for most evolutions and its a nice round number. I figured since the games have never had a level tied to trade evolution the first method makes the most since.

As for the Ability Pokeball thank you for that one, i'm pretty sure I can implement it. I have another poke ball that makes a pokemon shiny and I have that script working, and it looks similar. I hadn't thought of what happens with no hidden ability, but even if something bad does happen the easiest soloution is just to give a hidden ability to every pokemon in my game.

I'll play with these after work tonight and let you know the results. Thank you again.
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
Evolutions = STEELIX,Trade,,STEELIX,LevelInBall,METALCOAT
In the above statement for the first option does it still require Steelix to have a metalcoat during trade along with having metalcoat and an evolution ball while leveling to level 28? When readingthe script I don't think it does. I think the parameters are capped and it may not be possible to do everything I want with the Evolutionballs. They were suppose to be an alternative to trade but still require the same items. I'll wait for your response but I may just have to drop the item requirement with the evolutionballs.

EDIT: I also want to mention the Secret Ball script works and unlocks the first hidden ability as intended and if used on a Koffing or another pokemon without a hidden ability nothing happens. I made sure to include that interaction withen the poke ball's effect description as a warning stating that not all pokemon have hidden abilities. Also thanks for helping with this script.
 
Last edited:

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
Evolutions = STEELIX,TradeItem,METALCOAT,STEELIX,LevelInBall,METALCOAT
That would have Onix evolve into Steelix either by trading while holding a Metal Coat OR by levelling up from level 28 while in an Evolution Ball and holding a Metal Coat.

Good to hear about the Secret Ball.
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
Alright I will give it a try after work tonight. Thank you so much for your time. I appreciate it. Would you happen to know where the scripts for states and abilities is located at? I found where they are defined but not the code to input their functions.
 

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
By "states", do you mean statuses? Like burn, paralysis, etc.? If so, they are defined in the script called Status, just under the evolution script. Their effects are scattered in various places. You can press Ctrl + Shift + F while in the script editor to search all sections for :POISON to get an idea about how that works.

Abilities are generally in BattleHandlers_Abilities, but some abilities have effects that need to go in other places. It depends on what you want to do.
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
Yeah I meant status effects and thanks for the tips on how to find them. I had just discovered Ctrl + F last night while working on PBS txt documents, good to know it works in scripts too.

I recieved an error message starting with Poliwhirl/Politoed. They are at the top of the trade pokemon in alphabetical order so I am assuming the others may be wrong too. I took a screen shot of the error and the script. I am wondering if I have done something wrong or if their is a flaw in the script somewhere?
Let me know what you think and as always thank you for your time.

EDIT: I found I had used ,, when I should not have so please disregard the screenshots but now have another error message. I'm trying to figure out what it means but it does'nt look very specific other than the fact that something seems undefined in the pokemon txt. I'm not sure how to find out what is undefined though. Here is the message below:

[Pokémon Essentials version 19.1]

Exception: RuntimeError
Message: Undefined value in GameData::Item
File PBS/pokemon.txt, section 64, key Evolutions

Backtrace:
366:Compiler:331:in `checkEnumField'
366:Compiler:307:in `csvEnumField!'
367:Compiler_CompilePBS:516:in `block (2 levels) in compile_pokemon'
367:Compiler_CompilePBS:508:in `each'
367:Compiler_CompilePBS:508:in `block in compile_pokemon'
101:GameData:58:in `block in each'
101:GameData:58:in `each'
101:GameData:58:in `each'
367:Compiler_CompilePBS:504:in `compile_pokemon'
366:Compiler:703:in `compile_all'
 

Attachments

  • Script.png
    Script.png
    212.6 KB · Views: 7
  • Error Msg.png
    Error Msg.png
    185 KB · Views: 6
Last edited:

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
This is what I have for Kadabra below, is it correct? I have it the same for other pokemon without trade items. Do I still need to specify a level for non trade item evolutions?

Evolutions = ALAKAZAM,Trade,,ALAKAZAM,LevelInBall

Thanks for your help with this. I also noticed the error was talking about section 64 and Kadabra is the 64th pokemon so I figured out how you read the error message. I hadn't realized that until now.

EDIT: I tried adding level and have tried only using one , instead of ,, but it still says section 64 has an error. I'll have to look at it more after work.
 

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
You always need the three entries for evolutions: Species, Method, Parameter
So, your Evolutions = ALAKAZAM,Trade,,ALAKAZAM,LevelInBall line is missing the parameter for the LevelInBall method.
How you chose to set it up was to have the parameter be an item that the Pokémon needs to hold in order to evolve. If you don't want an item to be held, then you'll need to make a new evolution method (with a new name) that just checks whether the Pokémon is in an evolution ball like in my very first reply.
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
You always need the three entries for evolutions: Species, Method, Parameter
So, your Evolutions = ALAKAZAM,Trade,,ALAKAZAM,LevelInBall line is missing the parameter for the LevelInBall method.
How you chose to set it up was to have the parameter be an item that the Pokémon needs to hold in order to evolve. If you don't want an item to be held, then you'll need to make a new evolution method (with a new name) that just checks whether the Pokémon is in an evolution ball like in my very first reply.
Ok that makes sense, I was thinking the one script now did both functions. Adding the second script is easy so I don't expect anymore errors. Am I right to assume that the order of the two evolution methods does not matter since they are each their own script and have nothing to do with one another? I'll set this all up after work tonight and let you know how it goes. As always thank you, you've been a big help. I haven't had essentials very long but the community has proven to be friendly and helpful.
 

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
That's right, the order won't matter. In fact, because the data structure in v19 is modular, these new evolution methods can be placed anywhere! For example, you could create a new script section above Main for these new bits so you can keep them separate from base Essentials code, or create a plugin. It's obviously fine to put them in the Evolution script as well.
 

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
Well thats really good to know. I was worried if i pasted the wrong script somewhere it would cause problems and have been very careful. I think I will continue to keep everything seperated by what it does so its easy to find.

So I inputed the new script and recieved an error, I believe it is Poliwhirl specifically something to do with the Kingsrock. Heres the error message along with my PBS entry. I'm not sure what it means by it is not a positive integer.

Evolutions = POLIWRATH,Item,WATERSTONE,POLITOED,LevelInBall,KINGSROCK:

[Pokémon Essentials version 19.1]

Exception: RuntimeError
Message: Field KINGSROCK is not a positive integer
File PBS/pokemon.txt, section 61, key Evolutions

Backtrace:
366:Compiler:295:in `csvPosInt!'
367:Compiler_CompilePBS:514:in `block (2 levels) in compile_pokemon'
367:Compiler_CompilePBS:508:in `each'
367:Compiler_CompilePBS:508:in `block in compile_pokemon'
101:GameData:58:in `block in each'
101:GameData:58:in `each'
101:GameData:58:in `each'
367:Compiler_CompilePBS:504:in `compile_pokemon'
366:Compiler:703:in `compile_all'
[Elite Battle: DX] EBDX Compiler.rb:188:in `compile_all'

EDIT: I'm wondering if the error has something to do with the evolution stone required to evolve into Poliwrath or at least the way I inputed that information. This is the only trade pokemon with an evolution stone. Maybe I have too many parameters listed. (evolution stone, Evolution Ball + Kings Rock) I think that is only two parameters though.

EDIT 2: I dont think it has anything to do with the KIngs Rock. Is it possible the two scripts being used are conflicting? The original script had a level requirement and it looks like maybe its trying to read the Kings Rock as that level requirement? I'll copy and paste the two scripts below. If it is the issue I am fine scripting the level of evolution for pokemon of both scripts to be level 30 like Script 1. I'm sorry for any inconvienence my questions may have caused. I really do appreciate the time you have put into helping me solve these issues. Thank you.

Script 1:
GameData::Evolution.register({
  :id            => :LevelInBall,
  :parameter     => :Item,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= 30 && pkmn.poke_ball == :EVOLUTIONBALL && pkmn.item == parameter
  },
  :after_evolution_proc => proc { |pkmn, new_species, parameter, evo_species|
    next false if evo_species != new_species || !pkmn.hasItem?(parameter)
    pkmn.item = nil   # Item is now consumed
    next true
  }
})

Script 2 (original):
GameData::Evolution.register({
  :id            => :LevelInBall,
  :parameter     => Integer,
  :level_up_proc => proc { |pkmn, parameter|
    next pkmn.level >= parameter && pkmn.poke_ball == :EVOLUTIONBALL
  }
})
 
Last edited:

Pokemon Liberator

Novice
Member
Joined
Jul 18, 2021
Posts
27
Age
39
I think I have the issue sorted out. I used the following code, please let me know if looks correct but I sucessfully had onix evolve into steelix and gravler evolve into golem both at level 30.

Modified Script:
GameData::Evolution.register({
  :id            => :LevelInBall,
  :level_up_proc => proc { |pkmn,|
    next pkmn.level >= 30 && pkmn.poke_ball == :EVOLUTIONBALL
  }
})

This is my first attempt at modifying script but comparing the two scripts we have been working on I was able to configure it. The issue seemed to be in the original script where it used a parameter as an integer and it conflicted with the script that required an item.I dropped the level parameter so niether scripts look for an integer. Does it look ok and will it cause me problems in the future? Oh and just in case you don't reply back thank you for everything.
 

ThatWelshOne_

Umbreon User
Moderator
Joined
Sep 29, 2020
Posts
234
You can use the two scripts, but they need different names since they're both called "LevelInBall". I'm sorry, I hadn't realised you would end up using both of these methods, so I hadn't thought about giving them different names.
 
Top