- Pokémon Essentials Version
- v21.1 ✅
This is a port of Pokemon Liberator's Pokemon Broker v19 script for a Pokemon Broker, who will offer to buy your Pokemon.
The price of a Pokemon is set by a combination of base stats, and catch rate.
To use this in your game:
1) Copy the script into a new section of your RPG Maker XP program
2) Add the following script event to your NPC: sellPokemonToNPC()
The price of a Pokemon is set by a combination of base stats, and catch rate.
To use this in your game:
1) Copy the script into a new section of your RPG Maker XP program
2) Add the following script event to your NPC: sellPokemonToNPC()
- If you want the NPC to only buy a Pokemon of a certain type, e.g. Fire, you can use:
- sellPokemonToNPC(:FIRE)
Pokemon Broker:
################################################################################
# Pokemon Broker
################################################################################
def pbChooseAblePokemonByType(variableNumber, nameVarNumber, type = nil)
pbChoosePokemon(variableNumber, nameVarNumber, proc { |pkmn|
next false if pkmn.egg?
next true if type.nil? # Allow all Pokémon if type is not specified
next pkmn.hasType?(type)
})
end
def sellPokemonToNPC(pokemon_type = nil)
if pokemon_type.nil?
broker_text = "I'm looking to buy a Pokemon. I'll give you good money for it!"
else
broker_text = "I'm looking to buy a #{pokemon_type} Pokemon. I'll give you good money for it!"
end
Kernel.pbMessage(_INTL("#{broker_text}"))
if $player.able_pokemon_count <= 1
Kernel.pbMessage(_INTL("Hey, you can't sell your last Pokemon!"))
#break
else
eligible_pokemon = $player.party.select do |pkmn|
if pokemon_type
pkmn.hasType?(pokemon_type)
else
true
end
end
if eligible_pokemon.empty?
Kernel.pbMessage(_INTL("You have no Pokémon that can be sold."))
return
end
pbChooseAblePokemonByType(1, 3, pokemon_type)
chosen_index = pbGet(1)
if chosen_index == -1
return
end
chosen_pokemon = $player.pokemon_party[chosen_index]
total_stats = chosen_pokemon.baseStats[:HP] +
chosen_pokemon.baseStats[:ATTACK] +
chosen_pokemon.baseStats[:DEFENSE] +
chosen_pokemon.baseStats[:SPECIAL_ATTACK] +
chosen_pokemon.baseStats[:SPECIAL_DEFENSE] +
chosen_pokemon.baseStats[:SPEED]
species_data = GameData::Species.get(chosen_pokemon.species)
catch_rate = species_data.catch_rate
base_price = total_stats - (catch_rate * 1) + (chosen_pokemon.level * 2)
multiplier = 1
base_price *= 2 if chosen_pokemon.shiny?
#base_price *= 2 if chosen_pokemon.ot == "Alpha"
pokeball_price = (GameData::Item.get(species_data.egg_groups[0].to_sym).price rescue 0)
if pokeball_price > 0
base_price += pokeball_price
end
base_price += ((GameData::Item.get(chosen_pokemon.item).price rescue 0) / 2) if chosen_pokemon.item
if Kernel.pbConfirmMessage(_INTL("Would you like to sell your {1} for ${2}?", chosen_pokemon.name, base_price))
$player.remove_pokemon_at_index(chosen_index)
$player.money += base_price
Kernel.pbMessage(_INTL("You sold your {1} for ${2}.", chosen_pokemon.name, base_price))
else
Kernel.pbMessage("Player declined the sale.")
end
end
end
- Credits
- PokemonLiberator, Tsoukinator