- 19
- Posts
- 7
- Years
- Seen Aug 14, 2021
Hello!
So, Pokemon Essentials has a feature where trainers will send out a Pokemon that's strong against what the trainer is using, instead of just sending them out in the order defined in the PBS file. This is great, but sometimes you want a trainer that always sends out their strongest Pokemon last, or a similar effect. What I'm looking for is a way to bypass this decision and have trainers just send out their Pokemon in a set order.
I'm aware that this issue has been solved for previous versions of Essentials, but the relevant code was rewritten in v18 and the old fix no longer works. I've narrowed it down to this section here:
By adding a $game_switches number to turn the effect on and off and messing with the code I was able to generate some comical results, but not the result I'm looking for. What do?
EDIT:
For those in the future who stumble across this, with some help from a friend I figured it out. It was simply a matter of changing the following (changes in red):
With the switch "75" being whatever switch you use in your game, of course.
So, Pokemon Essentials has a feature where trainers will send out a Pokemon that's strong against what the trainer is using, instead of just sending them out in the order defined in the PBS file. This is great, but sometimes you want a trainer that always sends out their strongest Pokemon last, or a similar effect. What I'm looking for is a way to bypass this decision and have trainers just send out their Pokemon in a set order.
I'm aware that this issue has been solved for previous versions of Essentials, but the relevant code was rewritten in v18 and the old fix no longer works. I've narrowed it down to this section here:
Spoiler:
def pbDefaultChooseNewEnemy(idxBattler,party)
enemies = []
party.each_with_index do |p,i|
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
end
return -1 if enemies.length==0
return pbChooseBestNewEnemy(idxBattler,party,enemies)
end
def pbChooseBestNewEnemy(idxBattler,party,enemies)
return -1 if !enemies || enemies.length==0
best = -1
bestSum = 0
movesData = pbLoadMovesData
enemies.each do |i|
pkmn = party
sum = 0
pkmn.moves.each do |m|
next if m.id==0
moveData = movesData[m.id]
next if moveData[MOVE_BASE_DAMAGE]==0
@battle.battlers[idxBattler].eachOpposing do |b|
bTypes = b.pbTypes(true)
sum += PBTypes.getCombinedEffectiveness(moveData[MOVE_TYPE],
bTypes[0],bTypes[1],bTypes[2])
end
end
if best==-1 || sum>bestSum
best = i
bestSum = sum
end
end
return best
end
enemies = []
party.each_with_index do |p,i|
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
end
return -1 if enemies.length==0
return pbChooseBestNewEnemy(idxBattler,party,enemies)
end
def pbChooseBestNewEnemy(idxBattler,party,enemies)
return -1 if !enemies || enemies.length==0
best = -1
bestSum = 0
movesData = pbLoadMovesData
enemies.each do |i|
pkmn = party
sum = 0
pkmn.moves.each do |m|
next if m.id==0
moveData = movesData[m.id]
next if moveData[MOVE_BASE_DAMAGE]==0
@battle.battlers[idxBattler].eachOpposing do |b|
bTypes = b.pbTypes(true)
sum += PBTypes.getCombinedEffectiveness(moveData[MOVE_TYPE],
bTypes[0],bTypes[1],bTypes[2])
end
end
if best==-1 || sum>bestSum
best = i
bestSum = sum
end
end
return best
end
By adding a $game_switches number to turn the effect on and off and messing with the code I was able to generate some comical results, but not the result I'm looking for. What do?
EDIT:
For those in the future who stumble across this, with some help from a friend I figured it out. It was simply a matter of changing the following (changes in red):
Spoiler:
def pbDefaultChooseNewEnemy(idxBattler,party)
enemies = []
party.each_with_index do |p,i|
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
end
return -1 if !enemies || enemies.length==0
if !$game_switches[75] == true
return pbChooseBestNewEnemy(idxBattler,party,enemies)
else
return enemies[0]
end
end
enemies = []
party.each_with_index do |p,i|
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
end
return -1 if !enemies || enemies.length==0
if !$game_switches[75] == true
return pbChooseBestNewEnemy(idxBattler,party,enemies)
else
return enemies[0]
end
end
With the switch "75" being whatever switch you use in your game, of course.
Last edited: