Rewrote AI item usage (inc. adding Revives), various fixes/changes to AI, removed Struggle from PBS files, some bug fixes

This commit is contained in:
Maruno17
2023-04-23 17:52:39 +01:00
parent da182bd98a
commit ce549ab62a
34 changed files with 497 additions and 410 deletions

View File

@@ -171,7 +171,7 @@ class Battle::Battler
return true
end
def pbCanSynchronizeStatus?(newStatus, target)
def pbCanSynchronizeStatus?(newStatus, user)
return false if fainted?
# Trying to replace a status problem with another one
return false if self.status != :NONE
@@ -181,8 +181,8 @@ class Battle::Battler
hasImmuneType = false
case newStatus
when :POISON
# NOTE: target will have Synchronize, so it can't have Corrosion.
if !(target && target.hasActiveAbility?(:CORROSION))
# NOTE: user will have Synchronize, so it can't have Corrosion.
if !(user && user.hasActiveAbility?(:CORROSION))
hasImmuneType |= pbHasType?(:POISON)
hasImmuneType |= pbHasType?(:STEEL)
end
@@ -205,6 +205,7 @@ class Battle::Battler
return false
end
# Safeguard immunity
# NOTE: user will have Synchronize, so it can't have Infiltrator.
if pbOwnSide.effects[PBEffects::Safeguard] > 0 &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
return false

View File

@@ -43,19 +43,21 @@ class Battle::Battler
# Choice Band/Gorilla Tactics
@effects[PBEffects::ChoiceBand] = nil if !pbHasMove?(@effects[PBEffects::ChoiceBand])
if @effects[PBEffects::ChoiceBand] && move.id != @effects[PBEffects::ChoiceBand]
choiced_move_name = GameData::Move.get(@effects[PBEffects::ChoiceBand]).name
if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
if showMessages
msg = _INTL("The {1} only allows the use of {2}!", itemName, choiced_move_name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
choiced_move = GameData::Move.try_get(@effects[PBEffects::ChoiceBand])
if choiced_move
if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
if showMessages
msg = _INTL("The {1} only allows the use of {2}!", itemName, choiced_move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
elsif hasActiveAbility?(:GORILLATACTICS)
if showMessages
msg = _INTL("{1} can only use {2}!", pbThis, choiced_move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
return false
elsif hasActiveAbility?(:GORILLATACTICS)
if showMessages
msg = _INTL("{1} can only use {2}!", pbThis, choiced_move_name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
end
# Taunt
@@ -85,7 +87,7 @@ class Battle::Battler
end
# Assault Vest (prevents choosing status moves but doesn't prevent
# executing them)
if hasActiveItem?(:ASSAULTVEST) && move.statusMove? && move.id != :MEFIRST && commandPhase
if hasActiveItem?(:ASSAULTVEST) && move.statusMove? && move.function != "UseMoveTargetIsAboutToUse" && commandPhase
if showMessages
msg = _INTL("The effects of the {1} prevent status moves from being used!", itemName)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)