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

@@ -24,8 +24,12 @@ module GameData
if optional_suffix && !optional_suffix.empty?
ret = path + tr_type_data.id.to_s + optional_suffix + suffix
return ret if pbResolveBitmap(ret)
ret = path + sprintf("%03d", tr_type_data.id_number) + optional_suffix + suffix
return ret if pbResolveBitmap(ret)
end
ret = path + tr_type_data.id.to_s + suffix
return ret if pbResolveBitmap(ret)
ret = path + sprintf("%03d", tr_type_data.id_number) + suffix
return (pbResolveBitmap(ret)) ? ret : nil
end

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][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
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
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,22 +148,21 @@ 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
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

View File

@@ -748,9 +748,10 @@ class PokemonParty_Scene
end
when Input::UP
if currentsel >= Settings::MAX_PARTY_SIZE
begin
currentsel -= 1
end while currentsel > 0 && !@party[currentsel]
while currentsel > 0 && currentsel < Settings::MAX_PARTY_SIZE && !@party[currentsel]
currentsel -= 1
end
else
begin
currentsel -= 2

View File

@@ -22,10 +22,10 @@ class PBPokemon
itm = GameData::Item.try_get(item)
@item = itm ? itm.id : nil
@nature = nature
@move1 = move1 ? move1 : 0
@move2 = move2 ? move2 : 0
@move3 = move3 ? move3 : 0
@move4 = move4 ? move4 : 0
@move1 = move1 ? move1 : nil
@move2 = move2 ? move2 : nil
@move3 = move3 ? move3 : nil
@move4 = move4 ? move4 : nil
@ev = ev
end
@@ -55,7 +55,9 @@ class PBPokemon
move_data = GameData::Move.try_get(moves[i])
moveid.push(move_data.id) if move_data
end
moveid=[GameData::Move.get(1)] if moveid.length==0
if moveid.length==0
GameData::Move.each { |mov| moveid.push(mov.id); break }
end
return self.new(species, item, nature, moveid[0], moveid[1], moveid[2], moveid[3], ev_array)
end
@@ -154,9 +156,7 @@ class PBPokemon
pokemon=Pokemon.new(@species,level,trainer,false)
pokemon.item = @item
pokemon.personalID = rand(2**16) | rand(2**16) << 16
pokemon.personalID -= pokemon.personalID % 25
pokemon.personalID += nature
pokemon.personalID &= 0xFFFFFFFF
pokemon.nature = nature
pokemon.happiness=0
pokemon.moves[0] = Pokemon::Move.new(self.convertMove(@move1))
pokemon.moves[1] = Pokemon::Move.new(self.convertMove(@move2))
@@ -468,7 +468,7 @@ class BattleChallenge
end
def start(*args)
ensureType(@id)
t = ensureType(@id)
@currentChallenge=@id # must appear before pbStart
@bc.pbStart(t,@numRounds)
end
@@ -680,8 +680,9 @@ end
def pbBattleChallengeGraphic(event)
nextTrainer=pbBattleChallenge.nextTrainer
bttrainers=pbGetBTTrainers(pbBattleChallenge.currentChallenge)
filename=GameData::TrainerType.charset_filename_brief((bttrainers[nextTrainer][0] rescue 0))
filename=GameData::TrainerType.charset_filename_brief((bttrainers[nextTrainer][0] rescue nil))
begin
filename = "NPC 01" if nil_or_empty?(filename)
bitmap=AnimatedBitmap.new("Graphics/Characters/"+filename)
bitmap.dispose
event.character_name=filename

View File

@@ -1,5 +1,5 @@
def pbRandomMove
keys = GameData::Move::DATA.keys.sort
keys = GameData::Move::DATA.keys
loop do
move_id = keys[rand(keys.length)]
move = GameData::Move.get(move_id)
@@ -249,7 +249,7 @@ def pbRandomPokemonFromRule(rule,trainer)
iteration+=1
species=nil
level=rule.ruleset.suggestedLevel
keys = GameData::Species::DATA.keys.sort
keys = GameData::Species::DATA.keys
loop do
loop do
species = keys[rand(keys.length)]
@@ -910,9 +910,10 @@ def pbTrainerInfo(pokemonlist,trfile,rules)
if GameData::TrainerType.exists?(:YOUNGSTER) && rand(30) == 0
trainerid = :YOUNGSTER
else
tr_type_values = GameData::TrainerType::DATA.values
tr_typekeys = GameData::TrainerType::DATA.keys
loop do
tr_type_data = tr_type_values[rand(tr_type_values.length)]
tr_type = tr_typekeys[rand(tr_typekeys.length)]
tr_type_data = GameData::TrainerType.get(tr_type)
next if tr_type_data.base_money >= 100
trainerid = tr_type_data.id
end

View File

@@ -89,19 +89,19 @@ end
# Unused
def hasConst?(mod,constant)
return false if !mod || nil_or_empty?(constant)
return false if !mod || constant.nil?
return mod.const_defined?(constant.to_sym) rescue false
end
# Unused
def getConst(mod,constant)
return nil if !mod || nil_or_empty?(constant)
return nil if !mod || constant.nil?
return mod.const_get(constant.to_sym) rescue nil
end
# Unused
def getID(mod,constant)
return nil if !mod || nil_or_empty?(constant)
return nil if !mod || constant.nil?
if constant.is_a?(Symbol) || constant.is_a?(String)
if (mod.const_defined?(constant.to_sym) rescue false)
return mod.const_get(constant.to_sym) rescue 0

View File

@@ -925,7 +925,7 @@ module Compiler
end
new_format = true
values = $~[1].split(',').collect! { |v| v.strip.to_i }
values[1] = 0 if nil_or_empty?(values[1])
values[1] = 0 if !values[1]
map_number = values[0]
map_version = values[1]
# Add map encounter's data to records