More work on the AI, refactored stat stage multipliers

This commit is contained in:
Maruno17
2023-04-09 22:26:48 +01:00
parent 5d9cc71a99
commit a22c5ea89c
21 changed files with 618 additions and 651 deletions

View File

@@ -45,6 +45,13 @@ class Battle::Battler
attr_accessor :canRestoreIceFace # Whether Hail started in the round
attr_accessor :damageState
# These arrays should all have the same number of values in them
STAT_STAGE_MULTIPLIERS = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
STAT_STAGE_DIVISORS = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
ACC_EVA_STAGE_MULTIPLIERS = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9]
ACC_EVA_STAGE_DIVISORS = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
STAT_STAGE_MAXIMUM = 6 # Is also the minimum (-6)
#=============================================================================
# Complex accessors
#=============================================================================
@@ -240,10 +247,8 @@ class Battle::Battler
#=============================================================================
def pbSpeed
return 1 if fainted?
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
stage = @stages[:SPEED] + 6
speed = @speed * stageMul[stage] / stageDiv[stage]
stage = @stages[:SPEED] + STAT_STAGE_MAXIMUM
speed = @speed * STAT_STAGE_MULTIPLIERS[stage] / STAT_STAGE_DIVISORS[stage]
speedMult = 1.0
# Ability effects that alter calculated Speed
if abilityActive?

View File

@@ -3,7 +3,7 @@ class Battle::Battler
# Increase stat stages
#=============================================================================
def statStageAtMax?(stat)
return @stages[stat] >= 6
return @stages[stat] >= STAT_STAGE_MAXIMUM
end
def pbCanRaiseStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false)
@@ -33,7 +33,7 @@ class Battle::Battler
increment *= 2 if hasActiveAbility?(:SIMPLE)
end
# Change the stat stage
increment = [increment, 6 - @stages[stat]].min
increment = [increment, STAT_STAGE_MAXIMUM - @stages[stat]].min
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat] + increment
@@ -117,7 +117,7 @@ class Battle::Battler
# Decrease stat stages
#=============================================================================
def statStageAtMin?(stat)
return @stages[stat] <= -6
return @stages[stat] <= -STAT_STAGE_MAXIMUM
end
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false,
@@ -183,7 +183,7 @@ class Battle::Battler
increment *= 2 if hasActiveAbility?(:SIMPLE)
end
# Change the stat stage
increment = [increment, 6 + @stages[stat]].min
increment = [increment, STAT_STAGE_MAXIMUM + @stages[stat]].min
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat] - increment