Fixed partner trainers not having Bag items, fixed Flame Burst AI bug, added AI for Wonder Guard + switching

This commit is contained in:
Maruno17
2023-11-20 21:29:47 +00:00
parent d10892af47
commit e0dcdef321
7 changed files with 37 additions and 6 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
Audio/
Graphics/
Plugins/
Screenshots/
# Data folder, but not Data/Scripts folder or messages_core.dat
Data/*

View File

@@ -55,7 +55,7 @@ class Battle
end
else
items = pbGetOwnerItems(idxBattler)
items.delete_at(items.index(item))
items.delete_at(items.index(item)) if items
end
end

View File

@@ -81,7 +81,9 @@ class Battle
@mega_rings.each { |item| return GameData::Item.get(item).name if $bag.has?(item) }
else
trainer_items = pbGetOwnerItems(idxBattler)
@mega_rings.each { |item| return GameData::Item.get(item).name if trainer_items&.include?(item) }
if trainer_items
@mega_rings.each { |item| return GameData::Item.get(item).name if trainer_items.include?(item) }
end
end
end
return _INTL("Mega Ring")

View File

@@ -633,6 +633,7 @@ Battle::AI::Handlers::ShouldNotSwitch.add(:lethal_entry_hazards,
Battle::AI::Handlers::ShouldNotSwitch.add(:battler_has_super_effective_move,
proc { |battler, reserves, ai, battle|
next false if battler.effects[PBEffects::PerishSong] == 1
next false if battler.rough_end_of_round_damage >= battler.hp * 2 / 3
next false if battle.rules["suddendeath"]
has_super_effective_move = false
battler.battler.eachMove do |move|
@@ -676,3 +677,29 @@ Battle::AI::Handlers::ShouldNotSwitch.add(:battler_has_very_raised_stats,
next false
}
)
#===============================================================================
# Don't bother switching if the battler has Wonder Guard and is immune to the
# foe's damaging attacks.
#===============================================================================
Battle::AI::Handlers::ShouldNotSwitch.add(:battler_is_immune_via_wonder_guard,
proc { |battler, reserves, ai, battle|
next false if battler.effects[PBEffects::PerishSong] == 1
next false if battler.rough_end_of_round_damage >= battler.hp / 2
next false if !battler.has_active_ability?(:WONDERGUARD)
super_effective_foe = false
ai.each_foe_battler(battler.side) do |b|
next if !b.check_for_move do |m|
next false if !m.damagingMove?
eff = battler.effectiveness_of_type_against_battler(m.pbCalcType(b.battler), b, m)
next Effectiveness.super_effective?(eff)
end
super_effective_foe = true
break
end
if !super_effective_foe
PBDebug.log_ai("#{battler.name} won't switch after all because it has Wonder Guard and can't be damaged by foes")
end
next !super_effective_foe
}
)

View File

@@ -115,7 +115,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.copy("OHKO",
Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DamageTargetAlly",
proc { |score, move, user, target, ai, battle|
target.battler.allAllies.each do |b|
next if !b.near?(target.battler) || !b.battler.takesIndirectDamage?
next if !b.near?(target.battler) || !b.takesIndirectDamage?
score += 10
if ai.trainer.has_skill_flag?("HPAware")
score += 10 if b.hp <= b.totalhp / 16

View File

@@ -189,7 +189,8 @@ module BattleCreationHelperMethods
ally = NPCTrainer.new($PokemonGlobal.partner[1], $PokemonGlobal.partner[0])
ally.id = $PokemonGlobal.partner[2]
ally.party = $PokemonGlobal.partner[3]
ally_items[1] = ally.items.clone
data = GameData::Trainer.try_get($PokemonGlobal.partner[0], $PokemonGlobal.partner[1], $PokemonGlobal.partner[2])
ally_items[1] = data&.items.clone || []
trainer_array.push(ally)
pokemon_array = []
$player.party.each { |pkmn| pokemon_array.push(pkmn) }

View File

@@ -33,10 +33,10 @@ You will need Ruby installed to run these scripts. The intention is to replace t
The .gitignore file lists the files that will not be included in this repo. These are:
* The Audio/, Graphics/ and Plugins/ folders and everything in them.
* The Audio/, Graphics/, Plugins/ and Screenshots/ folders and everything in them.
* Everything in the Data/ folder, except for:
* The Data/Scripts/ folder and everything in there.
* Scripts.rxdata (a special version that just loads the individual script files).
* messages_core.dat, which contains common messages and is useful for translation projects.
* A few files in the main project folder (two of the Game.xxx files, and the RGSS dll file).
* A few files in the main project folder (two of the Game.xxx files, the RGSS dll file and errorlog.txt).
* Temporary files.