• 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!
Resource icon

v21.1 Pokemon Broker (port of Pokemon Liberator's v19 Script) 1.0

This resource pertains to version 21.1 of Pokémon Essentials.
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()
  • If you want the NPC to only buy a Pokemon of a certain type, e.g. Fire, you can use:
    • sellPokemonToNPC(:FIRE)
Credits: Pokemon Liberator
Pokemon Broker:
Expand Collapse Copy
################################################################################
# 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
Author
Tsoukinator
Views
513
First release
Last update

Ratings

0.00 star(s) 0 ratings
Back
Top