Seen 2 Days Ago
Posted 2 Weeks Ago
71 posts
289 Days
I'm working on a new capture script, but I'm extremely new to Ruby and I'm having some difficulties.

Basically, the idea is that after the third attempt to use Pokeball there are chances for the Pokemon to run away.
But, if the user Pokémon has abilitys or puts the wild Pokémon under the effect of trapping moves, this chance decreases.

In "def pbThrowPokeBall" I add a value to each Pokeball use with @turnCountBall +=1 and it worked fine.

I believe the shift verification script should be in this method:
def pbProcessTurn(choice,tryFlee=true)

And yes, when doing the shift check, EVERYTHING worked, even putting the "user", "target", "move" and "hasActiveAbility?" to identify the abilitys and moves.
Throughout the PokeBattle_Battler class these names are defined, but in def pbProcessTurn(choice,tryFlee=true) not yet, and I'm having a hard time defining this. Could someone give me a light?
The script is as follows:
Spoiler:
module NewCatch_System
CATCHFLEE = 326
end

#=============================================================================
# New Catch System
#=============================================================================
def pbBallCountforCatch
#=============================================================================
# Tentativa Número 3 de Pokébolas!
#=============================================================================
if @battle.wildBattle? && @battle.turnCountBall == 3
$game_variables[NewCatch_System::CATCHFLEE] = 1+rand(99)
# Usuário possui habilidade ShadowTag ou ArenaTrap
if @battle.user.hasActiveAbility?(:SHADOWTAG) or @battle.user.hasActiveAbility?(:ARENATRAP)
if $game_variables[NewCatch_System::CATCHFLEE] <= 15
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
end
# Pokémon inimigo está sob efeito de Mean Look ou Ingrain
if @battle.target.effects[PBEffects::MeanLook]>=0 or @battle.target.effects[PBEffects::Ingrain] or target.effects[PBEffects::Block]
if $game_variables[NewCatch_System::CATCHFLEE] <= 15
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
end
# Zero efeitos
if $game_variables[NewCatch_System::CATCHFLEE] <= 25
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
@battle.pbDisplay(_INTL("{1} está ficando incomodado!",pbThis))
end
#=============================================================================
# Tentativa Número 4 de Pokébolas!
#=============================================================================
if @battle.wildBattle? && @battle.turnCountBall == 4
$game_variables[NewCatch_System::CATCHFLEE] = 1+rand(99)
# Usuário possui habilidade ShadowTag ou ArenaTrap
if @battle.user.hasActiveAbility?(:SHADOWTAG) or @battle.user.hasActiveAbility?(:ARENATRAP)
if $game_variables[NewCatch_System::CATCHFLEE] <= 35
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
end
# Pokémon inimigo está sob efeito de Mean Look ou Ingrain
if @battle.target.effects[PBEffects::MeanLook]>=0 or @battle.target.effects[PBEffects::Ingrain] or target.effects[PBEffects::Block]
if $game_variables[NewCatch_System::CATCHFLEE] <= 35
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
end
# Zero efeitos
if $game_variables[NewCatch_System::CATCHFLEE] <= 50
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
@battle.pbDisplay(_INTL("{1} pode fugir a qualquer momento!",pbThis))
end
#=============================================================================
# Tentativa Número 5 de Pokébolas!
#=============================================================================
if @battle.wildBattle? && @battle.turnCountBall == 5
$game_variables[NewCatch_System::CATCHFLEE] = 1+rand(99)
# Usuário possui habilidade ShadowTag ou ArenaTrap
if @battle.user.hasActiveAbility?(:SHADOWTAG) or @battle.user.hasActiveAbility?(:ARENATRAP)
if $game_variables[NewCatch_System::CATCHFLEE] <= 50
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
end
# Pokémon inimigo está sob efeito de Mean Look ou Ingrain
if @battle.target.effects[PBEffects::MeanLook]>=0 or @battle.target.effects[PBEffects::Ingrain] or target.effects[PBEffects::Block]
if $game_variables[NewCatch_System::CATCHFLEE] <= 50
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
end
# Zero efeitos
if $game_variables[NewCatch_System::CATCHFLEE] <= 75
@battle.pbDisplay(_INTL("{1} fugiu da batalha!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
@battle.pbDisplay(_INTL("{1} O Pokémon está irritado e irá tentar fugir!",pbThis))
end
#=============================================================================
# Tentativa Número 6 de Pokébolas!
#=============================================================================
if @battle.wildBattle? && @battle.turnCountBall == 6
@battle.pbDisplay(_INTL("{1} deu fuga!",pbThis)) { pbSEPlay("Battle flee") }
@battle.decision = 3
pbEndTurn(choice)
return true
end
#=============================================================================
#=============================================================================
end


I call pbBallCountforCatch in pbProcessTurn(choice,tryFlee=true).
Credits are appreciated!
Essentials v18.1