Added class GameData::Stat

This commit is contained in:
Maruno17
2021-03-04 22:59:48 +00:00
parent 934e38662a
commit ff0c2f00c8
46 changed files with 1301 additions and 1202 deletions

View File

@@ -239,7 +239,7 @@ class PokeBattle_Battler
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[PBStats::SPEED] + 6
stage = @stages[:SPEED] + 6
speed = @speed*stageMul[stage]/stageDiv[stage]
speedMult = 1.0
# Ability effects that alter calculated Speed
@@ -283,12 +283,12 @@ class PokeBattle_Battler
# Queries about what the battler has
#=============================================================================
def plainStats
ret = []
ret[PBStats::ATTACK] = self.attack
ret[PBStats::DEFENSE] = self.defense
ret[PBStats::SPATK] = self.spatk
ret[PBStats::SPDEF] = self.spdef
ret[PBStats::SPEED] = self.speed
ret = {}
ret[:ATTACK] = self.attack
ret[:DEFENSE] = self.defense
ret[:SPECIAL_ATTACK] = self.spatk
ret[:SPECIAL_DEFENSE] = self.spdef
ret[:SPEED] = self.speed
return ret
end

View File

@@ -7,7 +7,7 @@ class PokeBattle_Battler
@index = idxBattler
@captured = false
@dummy = false
@stages = []
@stages = {}
@effects = []
@damageState = PokeBattle_DamageState.new
pbInitBlank
@@ -31,7 +31,8 @@ class PokeBattle_Battler
@pokemonIndex = -1
@participants = []
@moves = []
@iv = [0,0,0,0,0,0]
@iv = {}
GameData::Stat.each_main { |s| @iv[s.id] = 0 }
end
# Used by Future Sight only, when Future Sight's user is no longer in battle.
@@ -58,7 +59,8 @@ class PokeBattle_Battler
@pokemonIndex = idxParty
@participants = []
# moves intentionally not copied across here
@iv = pkmn.iv.clone
@iv = {}
GameData::Stat.each_main { |s| @iv[s.id] = pkmn.iv[s.id] }
@dummy = true
end
@@ -95,7 +97,8 @@ class PokeBattle_Battler
pkmn.moves.each_with_index do |m,i|
@moves[i] = PokeBattle_Move.from_pokemon_move(@battle,m)
end
@iv = pkmn.iv.clone
@iv = {}
GameData::Stat.each_main { |s| @iv[s.id] = pkmn.iv[s.id] }
end
def pbInitEffects(batonPass)
@@ -113,13 +116,13 @@ class PokeBattle_Battler
@effects[PBEffects::GastroAcid] = false if unstoppableAbility?
else
# These effects are passed on if Baton Pass is used
@stages[PBStats::ATTACK] = 0
@stages[PBStats::DEFENSE] = 0
@stages[PBStats::SPEED] = 0
@stages[PBStats::SPATK] = 0
@stages[PBStats::SPDEF] = 0
@stages[PBStats::EVASION] = 0
@stages[PBStats::ACCURACY] = 0
@stages[:ATTACK] = 0
@stages[:DEFENSE] = 0
@stages[:SPEED] = 0
@stages[:SPECIAL_ATTACK] = 0
@stages[:SPECIAL_DEFENSE] = 0
@stages[:ACCURACY] = 0
@stages[:EVASION] = 0
@effects[PBEffects::AquaRing] = false
@effects[PBEffects::Confusion] = 0
@effects[PBEffects::Curse] = false

View File

@@ -274,7 +274,7 @@ class PokeBattle_Battler
@spatk = target.spatk
@spdef = target.spdef
@speed = target.speed
PBStats.eachBattleStat { |s| @stages[s] = target.stages[s] }
GameData::Stat.each_battle { |s| @stages[s.id] = target.stages[s.id] }
if Settings::NEW_CRITICAL_HIT_RATE_MECHANICS
@effects[PBEffects::FocusEnergy] = target.effects[PBEffects::FocusEnergy]
@effects[PBEffects::LaserFocus] = target.effects[PBEffects::LaserFocus]

View File

@@ -15,7 +15,7 @@ class PokeBattle_Battler
# Check the stat stage
if statStageAtMax?(stat)
@battle.pbDisplay(_INTL("{1}'s {2} won't go any higher!",
pbThis,PBStats.getName(stat))) if showFailMsg
pbThis, GameData::Stat.get(stat).name)) if showFailMsg
return false
end
return true
@@ -33,15 +33,15 @@ class PokeBattle_Battler
# Change the stat stage
increment = [increment,6-@stages[stat]].min
if increment>0
s = PBStats.getName(stat); new = @stages[stat]+increment
PBDebug.log("[Stat change] #{pbThis}'s #{s}: #{@stages[stat]} -> #{new} (+#{increment})")
stat_name = GameData::Stat.get(stat).name
new = @stages[stat]+increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (+#{increment})")
@stages[stat] += increment
end
return increment
end
def pbRaiseStatStage(stat,increment,user,showAnim=true,ignoreContrary=false)
return false if !PBStats.validBattleStat?(stat)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbLowerStatStage(stat,increment,user,showAnim,true)
@@ -52,9 +52,9 @@ class PokeBattle_Battler
# Stat up animation and message
@battle.pbCommonAnimation("StatUp",self) if showAnim
arrStatTexts = [
_INTL("{1}'s {2} rose!",pbThis,PBStats.getName(stat)),
_INTL("{1}'s {2} rose sharply!",pbThis,PBStats.getName(stat)),
_INTL("{1}'s {2} rose drastically!",pbThis,PBStats.getName(stat))]
_INTL("{1}'s {2} rose!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose sharply!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose drastically!",pbThis,GameData::Stat.get(stat).name)]
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
# Trigger abilities upon stat gain
if abilityActive?
@@ -64,7 +64,6 @@ class PokeBattle_Battler
end
def pbRaiseStatStageByCause(stat,increment,user,cause,showAnim=true,ignoreContrary=false)
return false if !PBStats.validBattleStat?(stat)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbLowerStatStageByCause(stat,increment,user,cause,showAnim,true)
@@ -76,14 +75,14 @@ class PokeBattle_Battler
@battle.pbCommonAnimation("StatUp",self) if showAnim
if user.index==@index
arrStatTexts = [
_INTL("{1}'s {2} raised its {3}!",pbThis,cause,PBStats.getName(stat)),
_INTL("{1}'s {2} sharply raised its {3}!",pbThis,cause,PBStats.getName(stat)),
_INTL("{1}'s {2} drastically raised its {3}!",pbThis,cause,PBStats.getName(stat))]
_INTL("{1}'s {2} raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name)]
else
arrStatTexts = [
_INTL("{1}'s {2} raised {3}'s {4}!",user.pbThis,cause,pbThis(true),PBStats.getName(stat)),
_INTL("{1}'s {2} sharply raised {3}'s {4}!",user.pbThis,cause,pbThis(true),PBStats.getName(stat)),
_INTL("{1}'s {2} drastically raised {3}'s {4}!",user.pbThis,cause,pbThis(true),PBStats.getName(stat))]
_INTL("{1}'s {2} raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name)]
end
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
# Trigger abilities upon stat gain
@@ -148,7 +147,7 @@ class PokeBattle_Battler
# Check the stat stage
if statStageAtMin?(stat)
@battle.pbDisplay(_INTL("{1}'s {2} won't go any lower!",
pbThis,PBStats.getName(stat))) if showFailMsg
pbThis, GameData::Stat.get(stat).name)) if showFailMsg
return false
end
return true
@@ -166,15 +165,15 @@ class PokeBattle_Battler
# Change the stat stage
increment = [increment,6+@stages[stat]].min
if increment>0
s = PBStats.getName(stat); new = @stages[stat]-increment
PBDebug.log("[Stat change] #{pbThis}'s #{s}: #{@stages[stat]} -> #{new} (-#{increment})")
stat_name = GameData::Stat.get(stat).name
new = @stages[stat]-increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})")
@stages[stat] -= increment
end
return increment
end
def pbLowerStatStage(stat,increment,user,showAnim=true,ignoreContrary=false)
return false if !PBStats.validBattleStat?(stat)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbRaiseStatStage(stat,increment,user,showAnim,true)
@@ -185,9 +184,9 @@ class PokeBattle_Battler
# Stat down animation and message
@battle.pbCommonAnimation("StatDown",self) if showAnim
arrStatTexts = [
_INTL("{1}'s {2} fell!",pbThis,PBStats.getName(stat)),
_INTL("{1}'s {2} harshly fell!",pbThis,PBStats.getName(stat)),
_INTL("{1}'s {2} severely fell!",pbThis,PBStats.getName(stat))]
_INTL("{1}'s {2} fell!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly fell!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely fell!",pbThis,GameData::Stat.get(stat).name)]
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
# Trigger abilities upon stat loss
if abilityActive?
@@ -197,7 +196,6 @@ class PokeBattle_Battler
end
def pbLowerStatStageByCause(stat,increment,user,cause,showAnim=true,ignoreContrary=false)
return false if !PBStats.validBattleStat?(stat)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbRaiseStatStageByCause(stat,increment,user,cause,showAnim,true)
@@ -209,14 +207,14 @@ class PokeBattle_Battler
@battle.pbCommonAnimation("StatDown",self) if showAnim
if user.index==@index
arrStatTexts = [
_INTL("{1}'s {2} lowered its {3}!",pbThis,cause,PBStats.getName(stat)),
_INTL("{1}'s {2} harshly lowered its {3}!",pbThis,cause,PBStats.getName(stat)),
_INTL("{1}'s {2} severely lowered its {3}!",pbThis,cause,PBStats.getName(stat))]
_INTL("{1}'s {2} lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name)]
else
arrStatTexts = [
_INTL("{1}'s {2} lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),PBStats.getName(stat)),
_INTL("{1}'s {2} harshly lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),PBStats.getName(stat)),
_INTL("{1}'s {2} severely lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),PBStats.getName(stat))]
_INTL("{1}'s {2} lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name)]
end
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
# Trigger abilities upon stat loss
@@ -254,7 +252,7 @@ class PokeBattle_Battler
return false
end
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
return pbLowerStatStageByAbility(PBStats::ATTACK,1,user,false)
return pbLowerStatStageByAbility(:ATTACK,1,user,false)
end
# NOTE: These checks exist to ensure appropriate messages are shown if
# Intimidate is blocked somehow (i.e. the messages should mention the
@@ -266,8 +264,8 @@ class PokeBattle_Battler
return false
end
if abilityActive?
if BattleHandlers.triggerStatLossImmunityAbility(self.ability,self,PBStats::ATTACK,@battle,false) ||
BattleHandlers.triggerStatLossImmunityAbilityNonIgnorable(self.ability,self,PBStats::ATTACK,@battle,false)
if BattleHandlers.triggerStatLossImmunityAbility(self.ability,self,:ATTACK,@battle,false) ||
BattleHandlers.triggerStatLossImmunityAbilityNonIgnorable(self.ability,self,:ATTACK,@battle,false)
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
pbThis,abilityName,user.pbThis(true),user.abilityName))
return false
@@ -275,36 +273,36 @@ class PokeBattle_Battler
end
eachAlly do |b|
next if !b.abilityActive?
if BattleHandlers.triggerStatLossImmunityAllyAbility(b.ability,b,self,PBStats::ATTACK,@battle,false)
if BattleHandlers.triggerStatLossImmunityAllyAbility(b.ability,b,self,:ATTACK,@battle,false)
@battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by {4}'s {5}!",
pbThis,user.pbThis(true),user.abilityName,b.pbThis(true),b.abilityName))
return false
end
end
end
return false if !pbCanLowerStatStage?(PBStats::ATTACK,user)
return pbLowerStatStageByCause(PBStats::ATTACK,1,user,user.abilityName)
return false if !pbCanLowerStatStage?(:ATTACK,user)
return pbLowerStatStageByCause(:ATTACK,1,user,user.abilityName)
end
#=============================================================================
# Reset stat stages
#=============================================================================
def hasAlteredStatStages?
PBStats.eachBattleStat { |s| return true if @stages[s]!=0 }
GameData::Stat.each_battle { |s| return true if @stages[s.id] != 0 }
return false
end
def hasRaisedStatStages?
PBStats.eachBattleStat { |s| return true if @stages[s]>0 }
GameData::Stat.each_battle { |s| return true if @stages[s.id] > 0 }
return false
end
def hasLoweredStatStages?
PBStats.eachBattleStat { |s| return true if @stages[s]<0 }
GameData::Stat.each_battle { |s| return true if @stages[s.id] < 0 }
return false
end
def pbResetStatStages
PBStats.eachBattleStat { |s| @stages[s] = 0 }
GameData::Stat.each_battle { |s| @stages[s.id] = 0 }
end
end

View File

@@ -344,8 +344,8 @@ class PokeBattle_Battler
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
if user.pbCanLowerStatStage?(PBStats::ATTACK)
user.pbLowerStatStage(PBStats::ATTACK,2,nil)
if user.pbCanLowerStatStage?(:ATTACK)
user.pbLowerStatStage(:ATTACK,2,nil)
end
end
return false

View File

@@ -25,9 +25,9 @@ class PokeBattle_Battler
if target.opposes?(user)
# Rage
if target.effects[PBEffects::Rage] && !target.fainted?
if target.pbCanRaiseStatStage?(PBStats::ATTACK,target)
if target.pbCanRaiseStatStage?(:ATTACK,target)
@battle.pbDisplay(_INTL("{1}'s rage is building!",target.pbThis))
target.pbRaiseStatStage(PBStats::ATTACK,1,target)
target.pbRaiseStatStage(:ATTACK,1,target)
end
end
# Beak Blast