Fixed Battle Tower/Cups/Palace, fixed bug when using Metronome, fixed bad AI for Conversion/Conversion 2

This commit is contained in:
Maruno17
2021-05-04 20:36:49 +01:00
parent b563e73027
commit 3d88b85f56
10 changed files with 151 additions and 140 deletions

View File

@@ -1660,7 +1660,7 @@ class PokeBattle_Move_0B6 < PokeBattle_Move
def pbMoveFailed?(user,targets)
@metronomeMove = nil
move_keys = GameData::Move::DATA.keys.sort
move_keys = GameData::Move::DATA.keys
# NOTE: You could be really unlucky and roll blacklisted moves 1000 times in
# a row. This is too unlikely to care about, though.
1000.times do

View File

@@ -1311,23 +1311,25 @@ class PokeBattle_AI
end
#---------------------------------------------------------------------------
when "05E"
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
if !user.canChangeType?
score -= 90
else
types = []
user.eachMove do |m|
next if m.id==@id
has_possible_type = false
user.eachMoveWithIndex do |m,i|
break if Settings::MECHANICS_GENERATION >= 6 && i>0
next if GameData::Type.get(m.type).pseudo_type
next if user.pbHasType?(m.type)
types.push(m.type) if !types.include?(m.type)
has_possible_type = true
break
end
score -= 90 if types.length==0
score -= 90 if !has_possible_type
end
#---------------------------------------------------------------------------
when "05F"
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
if !user.canChangeType?
score -= 90
elsif !target.lastMoveUsed || GameData::Move.get(target.lastMoveUsed).pseudo_type
elsif !target.lastMoveUsed || !target.lastMoveUsedType ||
GameData::Type.get(target.lastMoveUsedType).pseudo_type
score -= 90
else
aType = nil
@@ -1339,13 +1341,14 @@ class PokeBattle_AI
if !aType
score -= 90
else
types = []
has_possible_type = false
GameData::Type.each do |t|
next if t.pseudo_type || user.pbHasType?(t.id) ||
!Effectiveness.resistant_type?(aType, t.id)
types.push(t.id)
!Effectiveness.resistant_type?(target.lastMoveUsedType, t.id)
has_possible_type = true
break
end
score -= 90 if types.length==0
score -= 90 if !has_possible_type
end
end
#---------------------------------------------------------------------------

View File

@@ -2,60 +2,61 @@
#
#===============================================================================
class PokeBattle_BattlePalace < PokeBattle_Battle
@@BattlePalaceUsualTable = [
61, 7, 32,
20, 25, 55,
70, 15, 15,
38, 31, 31,
20, 70, 10,
30, 20, 50,
56, 22, 22,
25, 15, 60,
69, 6, 25,
35, 10, 55,
62, 10, 28,
58, 37, 5,
34, 11, 55,
35, 5, 60,
56, 22, 22,
35, 45, 20,
44, 50, 6,
56, 22, 22,
30, 58, 12,
30, 13, 57,
40, 50, 10,
18, 70, 12,
88, 6, 6,
42, 50, 8,
56, 22, 22
]
@@BattlePalacePinchTable = [
61, 7, 32,
84, 8, 8,
32, 60, 8,
70, 15, 15,
70, 22, 8,
32, 58, 10,
56, 22, 22,
75, 15, 10,
28, 55, 17,
29, 6, 65,
30, 20, 50,
88, 6, 6,
29, 11, 60,
35, 60, 5,
56, 22, 22,
34, 60, 6,
34, 6, 60,
56, 22, 22,
30, 58, 12,
27, 6, 67,
25, 62, 13,
90, 5, 5,
22, 20, 58,
42, 5, 53,
56, 22, 22
]
# Percentage chances of choosing attack, defense, support moves
@@BattlePalaceUsualTable = {
:HARDY => [61, 7, 32],
:LONELY => [20, 25, 55],
:BRAVE => [70, 15, 15],
:ADAMANT => [38, 31, 31],
:NAUGHTY => [20, 70, 10],
:BOLD => [30, 20, 50],
:DOCILE => [56, 22, 22],
:RELAXED => [25, 15, 60],
:IMPISH => [69, 6, 25],
:LAX => [35, 10, 55],
:TIMID => [62, 10, 28],
:HASTY => [58, 37, 5],
:SERIOUS => [34, 11, 55],
:JOLLY => [35, 5, 60],
:NAIVE => [56, 22, 22],
:MODEST => [35, 45, 20],
:MILD => [44, 50, 6],
:QUIET => [56, 22, 22],
:BASHFUL => [30, 58, 12],
:RASH => [30, 13, 57],
:CALM => [40, 50, 10],
:GENTLE => [18, 70, 12],
:SASSY => [88, 6, 6],
:CAREFUL => [42, 50, 8],
:QUIRKY => [56, 22, 22]
}
@@BattlePalacePinchTable = {
:HARDY => [61, 7, 32],
:LONELY => [84, 8, 8],
:BRAVE => [32, 60, 8],
:ADAMANT => [70, 15, 15],
:NAUGHTY => [70, 22, 8],
:BOLD => [32, 58, 10],
:DOCILE => [56, 22, 22],
:RELAXED => [75, 15, 10],
:IMPISH => [28, 55, 17],
:LAX => [29, 6, 65],
:TIMID => [30, 20, 50],
:HASTY => [88, 6, 6],
:SERIOUS => [29, 11, 60],
:JOLLY => [35, 60, 5],
:NAIVE => [56, 22, 22],
:MODEST => [34, 60, 6],
:MILD => [34, 6, 60],
:QUIET => [56, 22, 22],
:BASHFUL => [30, 58, 12],
:RASH => [27, 6, 67],
:CALM => [25, 62, 13],
:GENTLE => [90, 5, 5],
:SASSY => [22, 20, 58],
:CAREFUL => [42, 5, 53],
:QUIRKY => [56, 22, 22]
}
def initialize(*arg)
super
@@ -92,57 +93,38 @@ class PokeBattle_BattlePalace < PokeBattle_Battle
return true
end
def pbPinchChange(idxPokemon)
thispkmn = @battlers[idxPokemon]
if !thispkmn.effects[PBEffects::Pinch] && thispkmn.status != :SLEEP &&
thispkmn.hp<=thispkmn.totalhp/2
nature = thispkmn.nature
thispkmn.effects[PBEffects::Pinch] = true
case nature
when :QUIET, :BASHFUL, :NAIVE, :QUIRKY, :HARDY, :DOCILE, :SERIOUS
pbDisplay(_INTL("{1} is eager for more!",thispkmn.pbThis))
when :CAREFUL, :RASH, :LAX, :SASSY, :MILD, :TIMID
pbDisplay(_INTL("{1} began growling deeply!",thispkmn.pbThis))
when :GENTLE, :ADAMANT, :HASTY, :LONELY, :RELAXED, :NAUGHTY
pbDisplay(_INTL("A glint appears in {1}'s eyes!",thispkmn.pbThis(true)))
when :JOLLY, :BOLD, :BRAVE, :CALM, :IMPISH, :MODEST
pbDisplay(_INTL("{1} is getting into position!",thispkmn.pbThis))
end
end
end
def pbRegisterMove(idxBattler,idxMove,_showMessages=true)
this_battler = @battlers[idxBattler]
if idxMove==-2
@choices[idxBattler][0] = :UseMove # Move
@choices[idxBattler][1] = -2 # "Incapable of using its power..."
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = -2 # "Incapable of using its power..."
@choices[idxBattler][2] = @struggle
@choices[idxBattler][3] = -1
else
@choices[idxBattler][0] = :UseMove # Move
@choices[idxBattler][1] = idxMove # Index of move
@choices[idxBattler][2] = this_battler.moves[idxMove] # Move object
@choices[idxBattler][3] = -1 # No target chosen
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = idxMove # Index of move to be used
@choices[idxBattler][2] = this_battler.moves[idxMove] # PokeBattle_Move object
@choices[idxBattler][3] = -1 # No target chosen yet
end
end
def pbAutoFightMenu(idxBattler)
this_battler = @battlers[idxBattler]
nature = this_battler.nature
nature = this_battler.nature.id
randnum = @battleAI.pbAIRandom(100)
category = 0
atkpercent = 0
defpercent = 0
if this_battler.effects[PBEffects::Pinch]
atkpercent = @@BattlePalacePinchTable[nature*3]
defpercent = atkpercent+@@BattlePalacePinchTable[nature*3+1]
atkpercent = @@BattlePalacePinchTable[nature][0]
defpercent = atkpercent+@@BattlePalacePinchTable[nature][1]
else
atkpercent = @@BattlePalaceUsualTable[nature*3]
defpercent = atkpercent+@@BattlePalaceUsualTable[nature*3+1]
atkpercent = @@BattlePalaceUsualTable[nature][0]
defpercent = atkpercent+@@BattlePalaceUsualTable[nature][1]
end
if randnum<atkpercent
category = 0
elsif randnum<defpercent
elsif randnum<atkpercent+defpercent
category = 1
else
category = 2
@@ -163,12 +145,28 @@ class PokeBattle_BattlePalace < PokeBattle_Battle
return true
end
def pbPinchChange(battler)
return if !battler || battler.fainted?
return if battler.effects[PBEffects::Pinch] || battler.status == :SLEEP
return if battler.hp > battler.totalhp / 2
nature = battler.nature.id
battler.effects[PBEffects::Pinch] = true
case nature
when :QUIET, :BASHFUL, :NAIVE, :QUIRKY, :HARDY, :DOCILE, :SERIOUS
pbDisplay(_INTL("{1} is eager for more!", battler.pbThis))
when :CAREFUL, :RASH, :LAX, :SASSY, :MILD, :TIMID
pbDisplay(_INTL("{1} began growling deeply!", battler.pbThis))
when :GENTLE, :ADAMANT, :HASTY, :LONELY, :RELAXED, :NAUGHTY
pbDisplay(_INTL("A glint appears in {1}'s eyes!", battler.pbThis(true)))
when :JOLLY, :BOLD, :BRAVE, :CALM, :IMPISH, :MODEST
pbDisplay(_INTL("{1} is getting into position!", battler.pbThis))
end
end
def pbEndOfRoundPhase
super
return if @decision!=0
for i in 0...4
pbPinchChange(i) if !@battlers[i].fainted?
end
return if @decision != 0
eachBattler { |b| pbPinchChange(b) }
end
end

View File

@@ -30,13 +30,17 @@ module PokeBattle_RecordedBattleModule
if trainer.is_a?(Array)
ret = []
for i in 0...trainer.length
ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id,trainer[i].badges.clone])
if trainer[i].is_a?(Player)
ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id,trainer[i].badges.clone])
else # NPCTrainer
ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id])
end
end
return ret
elsif trainer[i].is_a?(Player)
return [[trainer.trainer_type,trainer.name.clone,trainer.id,trainer.badges.clone]]
else
return [
[trainer.trainer_type,trainer.name.clone,trainer.id,trainer.badges.clone]
]
return [[trainer.trainer_type,trainer.name.clone,trainer.id]]
end
end
@@ -144,21 +148,20 @@ module BattlePlayerHelper
def self.pbCreateTrainerInfo(trainer)
return nil if !trainer
if trainer.length>1
ret = []
ret[0]=Player.new(trainer[0][1],trainer[0][0])
ret[0].id = trainer[0][2]
ret[0].badges = trainer[0][3]
ret[1] = Player.new(trainer[1][1],trainer[1][0])
ret[1].id = trainer[1][2]
ret[1].badges = trainer[1][3]
return ret
else
ret = Player.new(trainer[0][1],trainer[0][0])
ret.id = trainer[0][2]
ret.badges = trainer[0][3]
return ret
ret = []
trainer.each do |tr|
if tr.length == 4 # Player
t = Player.new(tr[1], tr[0])
t.id = tr[2]
t.badges = tr[3]
ret.push(t)
else # NPCTrainer
t = NPCTrainer.new(tr[1], tr[0])
t.id = tr[2]
ret.push(t)
end
end
return ret
end
end