- 8
- Posts
- 5
- Years
- Seen Apr 2, 2020
Couldn't find the code, so i wrote a script to enable the player to catch any pokemon of a trainer. (did this bc i wanted to make legendary encounter with more than a single pokemon, which were technically trainers)
Add this code above main:
Adjust WILDTRAINER_VARIABLE to the variable of your liking.
0=everything as usual
1=pokemon can be caught. pokemonID = former owner
2=pokemon can be caught. pokemonID = player
note does have to be switched of if e.g. the player joins team rocket
else the code might look like this:
known bugs:
- i think it breaks shadow-pokemon catch ability
Add this code above main:
Spoiler:
Code:
#enables the player to catch trainer pokemon, e.g. while being part of
#team rocket. To enable this, the game variable choosen:
#$catch_trainer[1] = $game_variables[26]
#number_variable_trainer_catch = 26
WILDTRAINER_VARIABLE=26
#has to be set. [1] The cought pokemon is still registered to the
#former owner. [2] The pokemon is listed as caught by the player.
module PokeBattle_BattleCommon
def pbThrowPokeBall(idxPokemon,ball,rareness=nil,showplayer=false)
itemname=PBItems.getName(ball)
battler=nil
if pbIsOpposing?(idxPokemon)
battler=self.battlers[idxPokemon]
else
battler=self.battlers[idxPokemon].pbOppositeOpposing
end
if battler.fainted?
battler=battler.pbPartner
end
pbDisplayBrief(_INTL("{1} threw one {2}!",self.pbPlayer.name,itemname))
if battler.fainted?
pbDisplay(_INTL("But there was no target..."))
return
end
#if @opponent && (!pbIsSnagBall?(ball) || !battler.isShadow?)
if @opponent && $game_variables[WILDTRAINER_VARIABLE] < 1
@scene.pbThrowAndDeflect(ball,1)
pbDisplay(_INTL("The Trainer blocked the Ball!\nDon't be a thief!"))
else
pokemon=battler.pokemon
species=pokemon.species
if $DEBUG && Input.press?(Input::CTRL)
shakes=4
else
if !rareness
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,pokemon.fSpecies,16)
rareness=dexdata.fgetb # Get rareness from dexdata file
dexdata.close
end
a=battler.totalhp
b=battler.hp
rareness=BallHandlers.modifyCatchRate(ball,rareness,self,battler)
x=(((a*3-b*2)*rareness)/(a*3)).floor
if battler.status==PBStatuses::SLEEP || battler.status==PBStatuses::FROZEN
x=(x*2.5).floor
elsif battler.status!=0
x=(x*1.5).floor
end
c=0
if $Trainer
if $Trainer.pokedexOwned>600
c=(x*2.5/6).floor
elsif $Trainer.pokedexOwned>450
c=(x*2/6).floor
elsif $Trainer.pokedexOwned>300
c=(x*1.5/6).floor
elsif $Trainer.pokedexOwned>150
c=(x*1/6).floor
elsif $Trainer.pokedexOwned>30
c=(x*0.5/6).floor
end
end
shakes=0; critical=false
if x>255 || BallHandlers.isUnconditional?(ball,self,battler)
shakes=4
else
x=1 if x<1
y = ( 65536 / ((255.0/x)**0.1875) ).floor
if USECRITICALCAPTURE && pbRandom(256)<c
critical=true
shakes=4 if pbRandom(65536)<y
else
shakes+=1 if pbRandom(65536)<y
shakes+=1 if pbRandom(65536)<y && shakes==1
shakes+=1 if pbRandom(65536)<y && shakes==2
shakes+=1 if pbRandom(65536)<y && shakes==3
end
end
end
PBDebug.log("[Threw Poké Ball] #{itemname}, #{shakes} shakes (4=capture)")
@scene.pbThrow(ball,shakes,critical,battler.index,showplayer)
case shakes
when 0
pbDisplay(_INTL("Oh no! The Pokémon broke free!"))
BallHandlers.onFailCatch(ball,self,battler)
when 1
pbDisplay(_INTL("Aww... It appeared to be caught!"))
BallHandlers.onFailCatch(ball,self,battler)
when 2
pbDisplay(_INTL("Aargh! Almost had it!"))
BallHandlers.onFailCatch(ball,self,battler)
when 3
pbDisplay(_INTL("Gah! It was so close, too!"))
BallHandlers.onFailCatch(ball,self,battler)
when 4
pbDisplayBrief(_INTL("Gotcha! {1} was caught!",pokemon.name))
@scene.pbThrowSuccess
#if pbIsSnagBall?(ball) && @opponent
if (pbIsSnagBall?(ball) && @opponent) || ($game_variables[26] > 0 && @opponent)
pbRemoveFromParty(battler.index,battler.pokemonIndex)
battler.pbReset
battler.participants=[]
else
@decision=4
end
if pbIsSnagBall?(ball) || $game_variables[26] > 1
pokemon.ot=self.pbPlayer.name
pokemon.trainerID=self.pbPlayer.id
end
BallHandlers.onCatch(ball,self,pokemon)
pokemon.ballused=pbGetBallType(ball)
((pokemon.makeUnmega if pokemon.isMega?) rescue nil)
pokemon.makeUnprimal rescue nil
pokemon.pbRecordFirstMoves
if GAINEXPFORCAPTURE
battler.captured=true
pbGainEXP
battler.captured=false
end
if !self.pbPlayer.hasOwned?(species)
self.pbPlayer.setOwned(species)
if $Trainer.pokedex
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pokemon.name))
@scene.pbShowPokedex(species)
end
end
pokemon.forcedForm = false if MultipleForms.hasFunction?(pokemon.species,"getForm")
@scene.pbHideCaptureBall
if @opponent && $game_switches[0076]
pokemon.pbUpdateShadowMoves rescue nil
@snaggedpokemon.push(pokemon)
else
pbStorePokemon(pokemon)
end
end
end
end
end
Adjust WILDTRAINER_VARIABLE to the variable of your liking.
0=everything as usual
1=pokemon can be caught. pokemonID = former owner
2=pokemon can be caught. pokemonID = player
note does have to be switched of if e.g. the player joins team rocket
else the code might look like this:
known bugs:
- i think it breaks shadow-pokemon catch ability