• 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

Resource Pokemon Broker 1

Pokemon Liberator

Cooltrainer
Member
Joined
Jul 18, 2021
Posts
145
Pokemon Liberator submitted a new resource:

Pokemon Broker - Appraises the chosen pokemon's value and allows the player to sell the chosen pokemon.

A script from my own game that has an NPC that asks for specific types of Pokemon that the NPC wishes to purchase. All types of Pokemon are also options. Just use the appropriate script commands at the bottom of the script. The event should have a conditional branch that makes sure the player has more than one pokemon and will refuse to purchase the player's last pokemon from their party. Their is a brief explanation of how to set this conditional branch up in an event. You can modify the...

Read more about this resource...
 

Tsoukinator

Novice
Member
Joined
Mar 12, 2024
Posts
30
Updated the script today to work with my version of 21.1.
I also added a checker for the NPC to refuse to sell to you if you only have 1 able pokemon left in your party.

Ruby:
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

# Script Command:
# sellPokemonToNPC - Will allow selling of any type.
# sellPokemonToNPC(:WATER) - Will allow selling only Water-type Pokémon.
# sellPokemonToNPC(:FIRE) - Will allow selling only FIRE-type Pokémon.

#Event Setup:
#Event Condition to prevent the last pokemon in the party from being sold should
#be $Trainer.ablePokemonCount==1 used in a condtional branch and the script commands
#placed in the else portion of the same condtional branch.
 
Back
Top