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

@@ -1121,17 +1121,18 @@ class Battle::Move::CategoryDependsOnHigherDamagePoisonTarget < Battle::Move::Po
def pbOnStartUse(user, targets)
target = targets[0]
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]
max_stage = Battle::Battler::STAT_STAGE_MAXIMUM
stageMul = Battle::Battler::STAT_STAGE_MULTIPLIERS
stageDiv = Battle::Battler::STAT_STAGE_DIVISORS
# Calculate user's effective attacking values
attack_stage = user.stages[:ATTACK] + 6
attack_stage = user.stages[:ATTACK] + max_stage
real_attack = (user.attack.to_f * stageMul[attack_stage] / stageDiv[attack_stage]).floor
special_attack_stage = user.stages[:SPECIAL_ATTACK] + 6
special_attack_stage = user.stages[:SPECIAL_ATTACK] + max_stage
real_special_attack = (user.spatk.to_f * stageMul[special_attack_stage] / stageDiv[special_attack_stage]).floor
# Calculate target's effective defending values
defense_stage = target.stages[:DEFENSE] + 6
defense_stage = target.stages[:DEFENSE] + max_stage
real_defense = (target.defense.to_f * stageMul[defense_stage] / stageDiv[defense_stage]).floor
special_defense_stage = target.stages[:SPECIAL_DEFENSE] + 6
special_defense_stage = target.stages[:SPECIAL_DEFENSE] + max_stage
real_special_defense = (target.spdef.to_f * stageMul[special_defense_stage] / stageDiv[special_defense_stage]).floor
# Perform simple damage calculation
physical_damage = real_attack.to_f / real_defense
@@ -1166,13 +1167,14 @@ class Battle::Move::CategoryDependsOnHigherDamageIgnoreTargetAbility < Battle::M
def pbOnStartUse(user, targets)
# Calculate user's effective attacking value
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]
max_stage = Battle::Battler::STAT_STAGE_MAXIMUM
stageMul = Battle::Battler::STAT_STAGE_MULTIPLIERS
stageDiv = Battle::Battler::STAT_STAGE_DIVISORS
atk = user.attack
atkStage = user.stages[:ATTACK] + 6
atkStage = user.stages[:ATTACK] + max_stage
realAtk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
spAtk = user.spatk
spAtkStage = user.stages[:SPECIAL_ATTACK] + 6
spAtkStage = user.stages[:SPECIAL_ATTACK] + max_stage
realSpAtk = (spAtk.to_f * stageMul[spAtkStage] / stageDiv[spAtkStage]).floor
# Determine move's category
@calcCategory = (realAtk > realSpAtk) ? 0 : 1
@@ -1187,7 +1189,7 @@ end
#===============================================================================
class Battle::Move::UseUserDefenseInsteadOfUserAttack < Battle::Move
def pbGetAttackStats(user, target)
return user.defense, user.stages[:DEFENSE] + 6
return user.defense, user.stages[:DEFENSE] + Battle::Battler::STAT_STAGE_MAXIMUM
end
end
@@ -1197,8 +1199,8 @@ end
#===============================================================================
class Battle::Move::UseTargetAttackInsteadOfUserAttack < Battle::Move
def pbGetAttackStats(user, target)
return target.spatk, target.stages[:SPECIAL_ATTACK] + 6 if specialMove?
return target.attack, target.stages[:ATTACK] + 6
return target.spatk, target.stages[:SPECIAL_ATTACK] + Battle::Battler::STAT_STAGE_MAXIMUM if specialMove?
return target.attack, target.stages[:ATTACK] + Battle::Battler::STAT_STAGE_MAXIMUM
end
end
@@ -1208,7 +1210,7 @@ end
#===============================================================================
class Battle::Move::UseTargetDefenseInsteadOfTargetSpDef < Battle::Move
def pbGetDefenseStats(user, target)
return target.defense, target.stages[:DEFENSE] + 6
return target.defense, target.stages[:DEFENSE] + Battle::Battler::STAT_STAGE_MAXIMUM
end
end
@@ -1264,7 +1266,7 @@ class Battle::Move::IgnoreTargetDefSpDefEvaStatStages < Battle::Move
def pbGetDefenseStats(user, target)
ret1, _ret2 = super
return ret1, 6 # Def/SpDef stat stage
return ret1, Battle::Battler::STAT_STAGE_MAXIMUM # Def/SpDef stat stage
end
end