From 3099cc48027d474b338316b1d03b20daa7dc3ed8 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sun, 20 Sep 2020 15:14:27 +0100 Subject: [PATCH 01/12] Fixed bugs with Metal Burst and Powder --- .../001_Battler/001_PokeBattle_Battler.rb | 4 +- .../001_Battler/007_Battler_UseMove.rb | 2 +- .../002_Move/003_Move_Usage_Calculations.rb | 61 +++++----- .../002_Move/005_Move_Effects_000-07F.rb | 4 +- .../002_Move/006_Move_Effects_080-0FF.rb | 6 +- .../004_AI/006_AI_Move_Utilities.rb | 53 +++++---- Data/Scripts/012_Battle/006_BattleHandlers.rb | 6 +- .../007_BattleHandlers_Abilities.rb | 108 +++++++++--------- .../012_Battle/008_BattleHandlers_Items.rb | 76 ++++++------ 9 files changed, 157 insertions(+), 163 deletions(-) diff --git a/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb b/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb index 33f333d63..00bbbda2b 100644 --- a/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb +++ b/Data/Scripts/012_Battle/001_Battler/001_PokeBattle_Battler.rb @@ -220,7 +220,7 @@ class PokeBattle_Battler stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2] stage = @stages[PBStats::SPEED] + 6 speed = @speed*stageMul[stage]/stageDiv[stage] - speedMult = 0x1000 + speedMult = 1.0 # Ability effects that alter calculated Speed if abilityActive? speedMult = BattleHandlers.triggerSpeedCalcAbility(@ability,self,speedMult) @@ -242,7 +242,7 @@ class PokeBattle_Battler speedMult *= 1.1 end # Calculation - return [(speed.to_f*speedMult/0x1000).round,1].max + return [(speed*speedMult).round,1].max end def pbWeight diff --git a/Data/Scripts/012_Battle/001_Battler/007_Battler_UseMove.rb b/Data/Scripts/012_Battle/001_Battler/007_Battler_UseMove.rb index a7211b8e4..1ccabad81 100644 --- a/Data/Scripts/012_Battle/001_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/012_Battle/001_Battler/007_Battler_UseMove.rb @@ -323,7 +323,7 @@ class PokeBattle_Battler @battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!")) user.lastMoveFailed = true w = @battle.pbWeather - if w!=PBWeather.RAINDANCE && w!=PBWeather.HEAVYRAIN && user.takesIndirectDamage? + if w!=PBWeather::Rain && w!=PBWeather::HeavyRain && user.takesIndirectDamage? oldHP = user.hp user.pbReduceHP((user.totalhp/4.0).round,false) user.pbFaint if user.fainted? diff --git a/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb b/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb index 41bb7f38d..ba817641a 100644 --- a/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb +++ b/Data/Scripts/012_Battle/002_Move/003_Move_Usage_Calculations.rb @@ -95,8 +95,8 @@ class PokeBattle_Move modifiers[BASE_ACC] = baseAcc modifiers[ACC_STAGE] = user.stages[PBStats::ACCURACY] modifiers[EVA_STAGE] = target.stages[PBStats::EVASION] - modifiers[ACC_MULT] = 0x1000 - modifiers[EVA_MULT] = 0x1000 + modifiers[ACC_MULT] = 1.0 + modifiers[EVA_MULT] = 1.0 pbCalcAccuracyModifiers(user,target,modifiers) # Check if move can't miss return true if modifiers[BASE_ACC]==0 @@ -107,8 +107,8 @@ class PokeBattle_Move stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3] accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage] evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage] - accuracy = (accuracy * modifiers[ACC_MULT] / 0x1000).round - evasion = (evasion * modifiers[EVA_MULT] / 0x1000).round + accuracy = (accuracy * modifiers[ACC_MULT]).round + evasion = (evasion * modifiers[EVA_MULT]).round evasion = 1 if evasion<1 # Calculation return @battle.pbRandom(100) < modifiers[BASE_ACC] * accuracy / evasion @@ -140,11 +140,11 @@ class PokeBattle_Move end # Other effects, inc. ones that set ACC_MULT or EVA_STAGE to specific values if @battle.field.effects[PBEffects::Gravity]>0 - modifiers[ACC_MULT] = (modifiers[ACC_MULT]*5/3).round + modifiers[ACC_MULT] *= 5/3.0 end if user.effects[PBEffects::MicleBerry] user.effects[PBEffects::MicleBerry] = false - modifiers[ACC_MULT] = (modifiers[ACC_MULT]*1.2).round + modifiers[ACC_MULT] *= 1.2 end modifiers[EVA_STAGE] = 0 if target.effects[PBEffects::Foresight] && modifiers[EVA_STAGE]>0 modifiers[EVA_STAGE] = 0 if target.effects[PBEffects::MiracleEye] && modifiers[EVA_STAGE]>0 @@ -244,14 +244,14 @@ class PokeBattle_Move defense = (defense.to_f*stageMul[defStage]/stageDiv[defStage]).floor end # Calculate all multiplier effects - multipliers = [0x1000,0x1000,0x1000,0x1000] + multipliers = [1.0, 1.0, 1.0, 1.0] pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers) # Main damage calculation - baseDmg = [(baseDmg * multipliers[BASE_DMG_MULT] / 0x1000).round,1].max - atk = [(atk * multipliers[ATK_MULT] / 0x1000).round,1].max - defense = [(defense * multipliers[DEF_MULT] / 0x1000).round,1].max - damage = (((2.0*user.level/5+2).floor*baseDmg*atk/defense).floor/50).floor+2 - damage = [(damage * multipliers[FINAL_DMG_MULT] / 0x1000).round,1].max + baseDmg = [(baseDmg * multipliers[BASE_DMG_MULT]).round, 1].max + atk = [(atk * multipliers[ATK_MULT]).round, 1].max + defense = [(defense * multipliers[DEF_MULT]).round, 1].max + damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2 + damage = [(damage * multipliers[FINAL_DMG_MULT]).round, 1].max target.damageState.calcDamage = damage end @@ -306,10 +306,10 @@ class PokeBattle_Move end # Other if user.effects[PBEffects::MeFirst] - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end if user.effects[PBEffects::HelpingHand] && !self.is_a?(PokeBattle_Confusion) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end if user.effects[PBEffects::Charge]>0 && isConst?(type,PBTypes,:ELECTRIC) multipliers[BASE_DMG_MULT] *= 2 @@ -341,15 +341,15 @@ class PokeBattle_Move case @battle.field.terrain when PBBattleTerrains::Electric if isConst?(type,PBTypes,:ELECTRIC) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end when PBBattleTerrains::Grassy if isConst?(type,PBTypes,:GRASS) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end when PBBattleTerrains::Psychic if isConst?(type,PBTypes,:PSYCHIC) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end end end @@ -361,28 +361,28 @@ class PokeBattle_Move if @battle.internalBattle if user.pbOwnedByPlayer? if physicalMove? && @battle.pbPlayer.numbadges>=NUM_BADGES_BOOST_ATTACK - multipliers[ATK_MULT] = (multipliers[ATK_MULT]*1.1).round + multipliers[ATK_MULT] *= 1.1 elsif specialMove? && @battle.pbPlayer.numbadges>=NUM_BADGES_BOOST_SPATK - multipliers[ATK_MULT] = (multipliers[ATK_MULT]*1.1).round + multipliers[ATK_MULT] *= 1.1 end end if target.pbOwnedByPlayer? if physicalMove? && @battle.pbPlayer.numbadges>=NUM_BADGES_BOOST_DEFENSE - multipliers[DEF_MULT] = (multipliers[DEF_MULT]*1.1).round + multipliers[DEF_MULT] *= 1.1 elsif specialMove? && @battle.pbPlayer.numbadges>=NUM_BADGES_BOOST_SPDEF - multipliers[DEF_MULT] = (multipliers[DEF_MULT]*1.1).round + multipliers[DEF_MULT] *= 1.1 end end end # Multi-targeting attacks if numTargets>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*0.75).round + multipliers[FINAL_DMG_MULT] *= 0.75 end # Weather case @battle.pbWeather when PBWeather::Sun, PBWeather::HarshSun if isConst?(type,PBTypes,:FIRE) - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 elsif isConst?(type,PBTypes,:WATER) multipliers[FINAL_DMG_MULT] /= 2 end @@ -390,17 +390,17 @@ class PokeBattle_Move if isConst?(type,PBTypes,:FIRE) multipliers[FINAL_DMG_MULT] /= 2 elsif isConst?(type,PBTypes,:WATER) - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 end when PBWeather::Sandstorm if target.pbHasType?(:ROCK) && specialMove? && @function!="122" # Psyshock - multipliers[DEF_MULT] = (multipliers[DEF_MULT]*1.5).round + multipliers[DEF_MULT] *= 1.5 end end # Critical hits if target.damageState.critical if NEWEST_BATTLE_MECHANICS - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 else multipliers[FINAL_DMG_MULT] *= 2 end @@ -415,12 +415,11 @@ class PokeBattle_Move if user.hasActiveAbility?(:ADAPTABILITY) multipliers[FINAL_DMG_MULT] *= 2 else - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 end end # Type effectiveness multipliers[FINAL_DMG_MULT] *= target.damageState.typeMod.to_f/PBTypeEffectiveness::NORMAL_EFFECTIVE - multipliers[FINAL_DMG_MULT] = multipliers[FINAL_DMG_MULT].round # Burn if user.status==PBStatuses::BURN && physicalMove? && damageReducedByBurn? && !user.hasActiveAbility?(:GUTS) @@ -431,19 +430,19 @@ class PokeBattle_Move !user.hasActiveAbility?(:INFILTRATOR) if target.pbOwnSide.effects[PBEffects::AuroraVeil]>0 if @battle.pbSideBattlerCount(target)>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*2/3).round + multipliers[FINAL_DMG_MULT] *= 2/3.0 else multipliers[FINAL_DMG_MULT] /= 2 end elsif target.pbOwnSide.effects[PBEffects::Reflect]>0 && physicalMove? if @battle.pbSideBattlerCount(target)>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*2/3).round + multipliers[FINAL_DMG_MULT] *= 2/3.0 else multipliers[FINAL_DMG_MULT] /= 2 end elsif target.pbOwnSide.effects[PBEffects::LightScreen]>0 && specialMove? if @battle.pbSideBattlerCount(target)>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*2/3).round + multipliers[FINAL_DMG_MULT] *= 2/3.0 else multipliers[FINAL_DMG_MULT] /= 2 end diff --git a/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb b/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb index 562007bad..629551f20 100644 --- a/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb +++ b/Data/Scripts/012_Battle/002_Move/005_Move_Effects_000-07F.rb @@ -2465,7 +2465,7 @@ end class PokeBattle_Move_073 < PokeBattle_FixedDamageMove def pbAddTarget(targets,user) return if user.lastFoeAttacker.length==0 - lastAttacker = user.lastFoeAttacker[user.lastFoeAttacker.last] + lastAttacker = user.lastFoeAttacker.last return if lastAttacker<0 || !user.opposes?(lastAttacker) user.pbAddTarget(targets,user,@battle.battlers[lastAttacker],self,false) end @@ -2546,7 +2546,7 @@ class PokeBattle_Move_076 < PokeBattle_Move def pbModifyDamage(damageMult,user,target) damageMult *= 2 if target.inTwoTurnAttack?("0CA") # Dig - damageMult = (damageMult/2.0).round if @battle.field.terrain==PBBattleTerrains::Grassy + damageMult /= 2 if @battle.field.terrain==PBBattleTerrains::Grassy return damageMult end end diff --git a/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb b/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb index 04af86e83..050a889de 100644 --- a/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb +++ b/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb @@ -422,7 +422,7 @@ class PokeBattle_Move_095 < PokeBattle_Move def pbModifyDamage(damageMult,user,target) damageMult *= 2 if target.inTwoTurnAttack?("0CA") # Dig - damageMult = (damageMult/2.0).round if @battle.field.terrain==PBBattleTerrains::Grassy + damageMult /= 2 if @battle.field.terrain==PBBattleTerrains::Grassy return damageMult end end @@ -2070,9 +2070,7 @@ class PokeBattle_Move_0C4 < PokeBattle_TwoTurnMove def pbBaseDamageMultiplier(damageMult,user,target) w = @battle.pbWeather - if w>0 && w!=PBWeather::Sun && w!=PBWeather::HarshSun - damageMult = (damageMult/2.0).round - end + damageMult /= 2 if w>0 && w!=PBWeather::Sun && w!=PBWeather::HarshSun return damageMult end end diff --git a/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb b/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb index da0ddc614..2bb76a15f 100644 --- a/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb @@ -275,7 +275,7 @@ class PokeBattle_AI defense = pbRoughStat(target,PBStats::SPDEF,skill) end ##### Calculate all multiplier effects ##### - multipliers = [0x1000,0x1000,0x1000,0x1000] + multipliers = [1.0, 1.0, 1.0, 1.0] # Ability effects that alter damage moldBreaker = false if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker? @@ -364,7 +364,7 @@ class PokeBattle_AI end # Parental Bond if skill>=PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.25).floor + multipliers[BASE_DMG_MULT] *= 1.25 end # Me First # TODO @@ -403,15 +403,15 @@ class PokeBattle_AI case @battle.field.terrain when PBBattleTerrains::Electric if isConst?(type,PBTypes,:ELECTRIC) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end when PBBattleTerrains::Grassy if isConst?(type,PBTypes,:GRASS) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end when PBBattleTerrains::Psychic if isConst?(type,PBTypes,:PSYCHIC) - multipliers[BASE_DMG_MULT] = (multipliers[BASE_DMG_MULT]*1.5).round + multipliers[BASE_DMG_MULT] *= 1.5 end end end @@ -427,9 +427,9 @@ class PokeBattle_AI # won't control the player's Pokémon. if target.pbOwnedByPlayer? if move.physicalMove?(type) && @battle.pbPlayer.numbadges>=NUM_BADGES_BOOST_DEFENSE - multipliers[DEF_MULT] = (multipliers[DEF_MULT]*1.1).round + multipliers[DEF_MULT] *= 1.1 elsif move.specialMove?(type) && @battle.pbPlayer.numbadges>=NUM_BADGES_BOOST_SPDEF - multipliers[DEF_MULT] = (multipliers[DEF_MULT]*1.1).round + multipliers[DEF_MULT] *= 1.1 end end end @@ -437,7 +437,7 @@ class PokeBattle_AI # Multi-targeting attacks if skill>=PBTrainerAI.highSkill if pbTargetsMultiple?(move,user) - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*0.75).round + multipliers[FINAL_DMG_MULT] *= 0.75 end end # Weather @@ -445,7 +445,7 @@ class PokeBattle_AI case @battle.pbWeather when PBWeather::Sun, PBWeather::HarshSun if isConst?(type,PBTypes,:FIRE) - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 elsif isConst?(type,PBTypes,:WATER) multipliers[FINAL_DMG_MULT] /= 2 end @@ -453,11 +453,11 @@ class PokeBattle_AI if isConst?(type,PBTypes,:FIRE) multipliers[FINAL_DMG_MULT] /= 2 elsif isConst?(type,PBTypes,:WATER) - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 end when PBWeather::Sandstorm if target.pbHasType?(:ROCK) && move.specialMove?(type) && move.function!="122" # Psyshock - multipliers[DEF_MULT] = (multipliers[DEF_MULT]*1.5).round + multipliers[DEF_MULT] *= 1.5 end end end @@ -469,7 +469,7 @@ class PokeBattle_AI if user.hasActiveAbility?(:ADAPTABILITY) multipliers[FINAL_DMG_MULT] *= 2 else - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*1.5).round + multipliers[FINAL_DMG_MULT] *= 1.5 end end end @@ -477,7 +477,6 @@ class PokeBattle_AI if skill>=PBTrainerAI.mediumSkill typemod = pbCalcTypeMod(type,user,target) multipliers[FINAL_DMG_MULT] *= typemod.to_f/PBTypeEffectiveness::NORMAL_EFFECTIVE - multipliers[FINAL_DMG_MULT] = multipliers[FINAL_DMG_MULT].round end # Burn if skill>=PBTrainerAI.highSkill @@ -492,19 +491,19 @@ class PokeBattle_AI if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR) if target.pbOwnSide.effects[PBEffects::AuroraVeil]>0 if @battle.pbSideBattlerCount(target)>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*2/3).round + multipliers[FINAL_DMG_MULT] *= 2/3.0 else multipliers[FINAL_DMG_MULT] /= 2 end elsif target.pbOwnSide.effects[PBEffects::Reflect]>0 && move.physicalMove?(type) if @battle.pbSideBattlerCount(target)>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*2/3).round + multipliers[FINAL_DMG_MULT] *= 2/3.0 else multipliers[FINAL_DMG_MULT] /= 2 end elsif target.pbOwnSide.effects[PBEffects::LightScreen]>0 && move.specialMove?(type) if @battle.pbSideBattlerCount(target)>1 - multipliers[FINAL_DMG_MULT] = (multipliers[FINAL_DMG_MULT]*2/3).round + multipliers[FINAL_DMG_MULT] *= 2/3.0 else multipliers[FINAL_DMG_MULT] /= 2 end @@ -522,11 +521,11 @@ class PokeBattle_AI # Move-specific final damage modifiers # TODO ##### Main damage calculation ##### - baseDmg = [(baseDmg * multipliers[BASE_DMG_MULT] / 0x1000).round,1].max - atk = [(atk * multipliers[ATK_MULT] / 0x1000).round,1].max - defense = [(defense * multipliers[DEF_MULT] / 0x1000).round,1].max - damage = (((2.0*user.level/5+2).floor*baseDmg*atk/defense).floor/50).floor+2 - damage = [(damage * multipliers[FINAL_DMG_MULT] / 0x1000).round,1].max + baseDmg = [(baseDmg * multipliers[BASE_DMG_MULT]).round, 1].max + atk = [(atk * multipliers[ATK_MULT]).round, 1].max + defense = [(defense * multipliers[DEF_MULT]).round, 1].max + damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2 + damage = [(damage * multipliers[FINAL_DMG_MULT]).round, 1].max # "AI-specific calculations below" # Increased critical hit rates if skill>=PBTrainerAI.mediumSkill @@ -585,8 +584,8 @@ class PokeBattle_AI modifiers[BASE_ACC] = baseAcc modifiers[ACC_STAGE] = user.stages[PBStats::ACCURACY] modifiers[EVA_STAGE] = target.stages[PBStats::EVASION] - modifiers[ACC_MULT] = 0x1000 - modifiers[EVA_MULT] = 0x1000 + modifiers[ACC_MULT] = 1.0 + modifiers[EVA_MULT] = 1.0 pbCalcAccuracyModifiers(user,target,modifiers,move,type,skill) # Check if move can't miss return 125 if modifiers[BASE_ACC]==0 @@ -597,8 +596,8 @@ class PokeBattle_AI stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3] accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage] evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage] - accuracy = (accuracy * modifiers[ACC_MULT] / 0x1000).round - evasion = (evasion * modifiers[EVA_MULT] / 0x1000).round + accuracy = (accuracy * modifiers[ACC_MULT]).round + evasion = (evasion * modifiers[EVA_MULT]).round evasion = 1 if evasion<1 return modifiers[BASE_ACC] * accuracy / evasion end @@ -642,10 +641,10 @@ class PokeBattle_AI # Other effects, inc. ones that set ACC_MULT or EVA_STAGE to specific values if skill>=PBTrainerAI.mediumSkill if @battle.field.effects[PBEffects::Gravity]>0 - modifiers[ACC_MULT] = (modifiers[ACC_MULT]*5/3).round + modifiers[ACC_MULT] *= 5/3.0 end if user.effects[PBEffects::MicleBerry] - modifiers[ACC_MULT] = (modifiers[ACC_MULT]*1.2).round + modifiers[ACC_MULT] *= 1.2 end modifiers[EVA_STAGE] = 0 if target.effects[PBEffects::Foresight] && modifiers[EVA_STAGE]>0 modifiers[EVA_STAGE] = 0 if target.effects[PBEffects::MiracleEye] && modifiers[EVA_STAGE]>0 diff --git a/Data/Scripts/012_Battle/006_BattleHandlers.rb b/Data/Scripts/012_Battle/006_BattleHandlers.rb index e159defcd..b0080dba5 100644 --- a/Data/Scripts/012_Battle/006_BattleHandlers.rb +++ b/Data/Scripts/012_Battle/006_BattleHandlers.rb @@ -578,16 +578,16 @@ def pbBattleGem(user,type,move,mults,moveType) return if !isConst?(moveType,PBTypes,type) user.effects[PBEffects::GemConsumed] = user.item if NEWEST_BATTLE_MECHANICS - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.3).round + mults[BASE_DMG_MULT] *= 1.3 else - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round + mults[BASE_DMG_MULT] *= 1.5 end end def pbBattleTypeWeakingBerry(type,moveType,target,mults) return if !isConst?(moveType,PBTypes,type) return if PBTypes.resistant?(target.damageState.typeMod) && !isConst?(moveType,PBTypes,:NORMAL) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]/2).round + mults[FINAL_DMG_MULT] /= 2 target.damageState.berryWeakened = true target.battle.pbCommonAnimation("EatBerry",target) end diff --git a/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb b/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb index 031aab5f7..6f685224d 100644 --- a/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb +++ b/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb @@ -11,7 +11,7 @@ BattleHandlers::SpeedCalcAbility.add(:CHLOROPHYLL, BattleHandlers::SpeedCalcAbility.add(:QUICKFEET, proc { |ability,battler,mult| - next (mult*1.5).round if battler.pbHasAnyStatus? + next mult*1.5 if battler.pbHasAnyStatus? } ) @@ -767,13 +767,13 @@ BattleHandlers::MoveBaseTypeModifierAbility.add(:REFRIGERATE, BattleHandlers::AccuracyCalcUserAbility.add(:COMPOUNDEYES, proc { |ability,mods,user,target,move,type| - mods[ACC_MULT] = (mods[ACC_MULT]*1.3).round + mods[ACC_MULT] *= 1.3 } ) BattleHandlers::AccuracyCalcUserAbility.add(:HUSTLE, proc { |ability,mods,user,target,move,type| - mods[ACC_MULT] = (mods[ACC_MULT]*0.8).round if move.physicalMove? + mods[ACC_MULT] *= 0.8 if move.physicalMove? } ) @@ -797,7 +797,7 @@ BattleHandlers::AccuracyCalcUserAbility.add(:UNAWARE, BattleHandlers::AccuracyCalcUserAbility.add(:VICTORYSTAR, proc { |ability,mods,user,target,move,type| - mods[ACC_MULT] = (mods[ACC_MULT]*1.1).round + mods[ACC_MULT] *= 1.1 } ) @@ -807,7 +807,7 @@ BattleHandlers::AccuracyCalcUserAbility.add(:VICTORYSTAR, BattleHandlers::AccuracyCalcUserAllyAbility.add(:VICTORYSTAR, proc { |ability,mods,user,target,move,type| - mods[ACC_MULT] = (mods[ACC_MULT]*1.1).round + mods[ACC_MULT] *= 1.1 } ) @@ -830,7 +830,7 @@ BattleHandlers::AccuracyCalcTargetAbility.add(:NOGUARD, BattleHandlers::AccuracyCalcTargetAbility.add(:SANDVEIL, proc { |ability,mods,user,target,move,type| if target.battle.pbWeather==PBWeather::Sandstorm - mods[EVA_MULT] = (mods[EVA_MULT]*1.25).round + mods[EVA_MULT] *= 1.25 end } ) @@ -838,7 +838,7 @@ BattleHandlers::AccuracyCalcTargetAbility.add(:SANDVEIL, BattleHandlers::AccuracyCalcTargetAbility.add(:SNOWCLOAK, proc { |ability,mods,user,target,move,type| if target.battle.pbWeather==PBWeather::Hail - mods[EVA_MULT] = (mods[EVA_MULT]*1.25).round + mods[EVA_MULT] *= 1.25 end } ) @@ -875,7 +875,7 @@ BattleHandlers::AccuracyCalcTargetAbility.add(:WONDERSKIN, BattleHandlers::DamageCalcUserAbility.add(:AERILATE, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if move.powerBoost + mults[BASE_DMG_MULT] *= 1.2 if move.powerBoost } ) @@ -886,7 +886,7 @@ BattleHandlers::DamageCalcUserAbility.add(:ANALYTIC, if (target.battle.choices[target.index][0]!=:UseMove && target.battle.choices[target.index][0]!=:Shift) || target.movedThisRound? - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.3).round + mults[BASE_DMG_MULT] *= 1.3 end } ) @@ -894,21 +894,21 @@ BattleHandlers::DamageCalcUserAbility.add(:ANALYTIC, BattleHandlers::DamageCalcUserAbility.add(:BLAZE, proc { |ability,user,target,move,mults,baseDmg,type| if user.hp<=user.totalhp/3 && isConst?(type,PBTypes,:FIRE) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) BattleHandlers::DamageCalcUserAbility.add(:DEFEATIST, proc { |ability,user,target,move,mults,baseDmg,type| - mults[ATK_MULT] = (mults[ATK_MULT]*0.5).round if user.hp<=user.totalhp/2 + mults[ATK_MULT] /= 2 if user.hp<=user.totalhp/2 } ) BattleHandlers::DamageCalcUserAbility.add(:FLAREBOOST, proc { |ability,user,target,move,mults,baseDmg,type| if user.burned? && move.specialMove? - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round + mults[BASE_DMG_MULT] *= 1.5 end } ) @@ -916,7 +916,7 @@ BattleHandlers::DamageCalcUserAbility.add(:FLAREBOOST, BattleHandlers::DamageCalcUserAbility.add(:FLASHFIRE, proc { |ability,user,target,move,mults,baseDmg,type| if user.effects[PBEffects::FlashFire] && isConst?(type,PBTypes,:FIRE) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) @@ -925,7 +925,7 @@ BattleHandlers::DamageCalcUserAbility.add(:FLOWERGIFT, proc { |ability,user,target,move,mults,baseDmg,type| w = user.battle.pbWeather if move.physicalMove? && (w==PBWeather::Sun || w==PBWeather::HarshSun) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) @@ -933,7 +933,7 @@ BattleHandlers::DamageCalcUserAbility.add(:FLOWERGIFT, BattleHandlers::DamageCalcUserAbility.add(:GUTS, proc { |ability,user,target,move,mults,baseDmg,type| if user.pbHasAnyStatus? && move.physicalMove? - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) @@ -948,19 +948,19 @@ BattleHandlers::DamageCalcUserAbility.copy(:HUGEPOWER,:PUREPOWER) BattleHandlers::DamageCalcUserAbility.add(:HUSTLE, proc { |ability,user,target,move,mults,baseDmg,type| - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round if move.physicalMove? + mults[ATK_MULT] *= 1.5 if move.physicalMove? } ) BattleHandlers::DamageCalcUserAbility.add(:IRONFIST, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if move.punchingMove? + mults[BASE_DMG_MULT] *= 1.2 if move.punchingMove? } ) BattleHandlers::DamageCalcUserAbility.add(:MEGALAUNCHER, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round if move.pulseMove? + mults[BASE_DMG_MULT] *= 1.5 if move.pulseMove? } ) @@ -969,7 +969,7 @@ BattleHandlers::DamageCalcUserAbility.add(:MINUS, next if !move.specialMove? user.eachAlly do |b| next if !b.hasActiveAbility?([:MINUS,:PLUS]) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 break end } @@ -980,7 +980,7 @@ BattleHandlers::DamageCalcUserAbility.copy(:MINUS,:PLUS) BattleHandlers::DamageCalcUserAbility.add(:NEUROFORCE, proc { |ability,user,target,move,mults,baseDmg,type| if PBTypes.superEffective?(target.damageState.typeMod) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*1.25).round + mults[FINAL_DMG_MULT] *= 1.25 end } ) @@ -988,14 +988,14 @@ BattleHandlers::DamageCalcUserAbility.add(:NEUROFORCE, BattleHandlers::DamageCalcUserAbility.add(:OVERGROW, proc { |ability,user,target,move,mults,baseDmg,type| if user.hp<=user.totalhp/3 && isConst?(type,PBTypes,:GRASS) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) BattleHandlers::DamageCalcUserAbility.add(:RECKLESS, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if move.recoilMove? + mults[BASE_DMG_MULT] *= 1.2 if move.recoilMove? } ) @@ -1003,9 +1003,9 @@ BattleHandlers::DamageCalcUserAbility.add(:RIVALRY, proc { |ability,user,target,move,mults,baseDmg,type| if user.gender!=2 && target.gender!=2 if user.gender==target.gender - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.25).round + mults[BASE_DMG_MULT] *= 1.25 else - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*0.75).round + mults[BASE_DMG_MULT] *= 0.75 end end } @@ -1017,22 +1017,20 @@ BattleHandlers::DamageCalcUserAbility.add(:SANDFORCE, (isConst?(type,PBTypes,:ROCK) || isConst?(type,PBTypes,:GROUND) || isConst?(type,PBTypes,:STEEL)) - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.3).round + mults[BASE_DMG_MULT] *= 1.3 end } ) BattleHandlers::DamageCalcUserAbility.add(:SHEERFORCE, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.3).round if move.addlEffect>0 + mults[BASE_DMG_MULT] *= 1.3 if move.addlEffect>0 } ) BattleHandlers::DamageCalcUserAbility.add(:SLOWSTART, proc { |ability,user,target,move,mults,baseDmg,type| - if user.turnCount<=5 && move.physicalMove? - mults[ATK_MULT] = (mults[ATK_MULT]*0.5).round - end + mults[ATK_MULT] /= 2 if user.turnCount<=5 && move.physicalMove? } ) @@ -1040,7 +1038,7 @@ BattleHandlers::DamageCalcUserAbility.add(:SOLARPOWER, proc { |ability,user,target,move,mults,baseDmg,type| w = user.battle.pbWeather if move.specialMove? && (w==PBWeather::Sun || w==PBWeather::HarshSun) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) @@ -1048,7 +1046,7 @@ BattleHandlers::DamageCalcUserAbility.add(:SOLARPOWER, BattleHandlers::DamageCalcUserAbility.add(:SNIPER, proc { |ability,user,target,move,mults,baseDmg,type| if target.damageState.critical - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*1.5).round + mults[FINAL_DMG_MULT] *= 1.5 end } ) @@ -1061,28 +1059,28 @@ BattleHandlers::DamageCalcUserAbility.add(:STAKEOUT, BattleHandlers::DamageCalcUserAbility.add(:STEELWORKER, proc { |ability,user,target,move,mults,baseDmg,type| - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round if isConst?(type,PBTypes,:STEEL) + mults[ATK_MULT] *= 1.5 if isConst?(type,PBTypes,:STEEL) } ) BattleHandlers::DamageCalcUserAbility.add(:STRONGJAW, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round if move.bitingMove? + mults[BASE_DMG_MULT] *= 1.5 if move.bitingMove? } ) BattleHandlers::DamageCalcUserAbility.add(:SWARM, proc { |ability,user,target,move,mults,baseDmg,type| if user.hp<=user.totalhp/3 && isConst?(type,PBTypes,:BUG) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) BattleHandlers::DamageCalcUserAbility.add(:TECHNICIAN, proc { |ability,user,target,move,mults,baseDmg,type| - if user.index!=target.index && move.id>0 && baseDmg*mults[BASE_DMG_MULT]/0x1000<=60 - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round + if user.index!=target.index && move.id>0 && baseDmg*mults[BASE_DMG_MULT]<=60 + mults[BASE_DMG_MULT] *= 1.5 end } ) @@ -1096,21 +1094,21 @@ BattleHandlers::DamageCalcUserAbility.add(:TINTEDLENS, BattleHandlers::DamageCalcUserAbility.add(:TORRENT, proc { |ability,user,target,move,mults,baseDmg,type| if user.hp<=user.totalhp/3 && isConst?(type,PBTypes,:WATER) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) BattleHandlers::DamageCalcUserAbility.add(:TOUGHCLAWS, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*4/3.0).round if move.contactMove? + mults[BASE_DMG_MULT] *= 4/3.0 if move.contactMove? } ) BattleHandlers::DamageCalcUserAbility.add(:TOXICBOOST, proc { |ability,user,target,move,mults,baseDmg,type| if user.poisoned? && move.physicalMove? - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round + mults[BASE_DMG_MULT] *= 1.5 end } ) @@ -1128,7 +1126,7 @@ BattleHandlers::DamageCalcUserAbility.add(:WATERBUBBLE, BattleHandlers::DamageCalcUserAllyAbility.add(:BATTERY, proc { |ability,user,target,move,mults,baseDmg,type| next if !move.specialMove? - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*1.3).round + mults[FINAL_DMG_MULT] *= 1.3 } ) @@ -1136,7 +1134,7 @@ BattleHandlers::DamageCalcUserAllyAbility.add(:FLOWERGIFT, proc { |ability,user,target,move,mults,baseDmg,type| w = user.battle.pbWeather if move.physicalMove? && (w==PBWeather::Sun || w==PBWeather::HarshSun) - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end } ) @@ -1148,7 +1146,7 @@ BattleHandlers::DamageCalcUserAllyAbility.add(:FLOWERGIFT, BattleHandlers::DamageCalcTargetAbility.add(:DRYSKIN, proc { |ability,user,target,move,mults,baseDmg,type| if isConst?(type,PBTypes,:FIRE) - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.25).round + mults[BASE_DMG_MULT] *= 1.25 end } ) @@ -1156,7 +1154,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:DRYSKIN, BattleHandlers::DamageCalcTargetAbility.add(:FILTER, proc { |ability,user,target,move,mults,baseDmg,type| if PBTypes.superEffective?(target.damageState.typeMod) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.75).round + mults[FINAL_DMG_MULT] *= 0.75 end } ) @@ -1167,7 +1165,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:FLOWERGIFT, proc { |ability,user,target,move,mults,baseDmg,type| w = user.battle.pbWeather if move.specialMove? && (w==PBWeather::Sun || w==PBWeather::HarshSun) - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round + mults[DEF_MULT] *= 1.5 end } ) @@ -1175,7 +1173,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:FLOWERGIFT, BattleHandlers::DamageCalcTargetAbility.add(:FLUFFY, proc { |ability,user,target,move,mults,baseDmg,type| mults[FINAL_DMG_MULT] *= 2 if isConst?(move.calcType,PBTypes,:FIRE) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.5).round if move.contactMove? + mults[FINAL_DMG_MULT] /= 2 if move.contactMove? } ) @@ -1188,21 +1186,21 @@ BattleHandlers::DamageCalcTargetAbility.add(:FURCOAT, BattleHandlers::DamageCalcTargetAbility.add(:GRASSPELT, proc { |ability,user,target,move,mults,baseDmg,type| if user.battle.field.terrain==PBBattleTerrains::Grassy - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round + mults[DEF_MULT] *= 1.5 end } ) BattleHandlers::DamageCalcTargetAbility.add(:HEATPROOF, proc { |ability,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*0.5).round if isConst?(type,PBTypes,:FIRE) + mults[BASE_DMG_MULT] /= 2 if isConst?(type,PBTypes,:FIRE) } ) BattleHandlers::DamageCalcTargetAbility.add(:MARVELSCALE, proc { |ability,user,target,move,mults,baseDmg,type| if target.pbHasAnyStatus? && move.physicalMove? - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round + mults[DEF_MULT] *= 1.5 end } ) @@ -1210,7 +1208,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:MARVELSCALE, BattleHandlers::DamageCalcTargetAbility.add(:MULTISCALE, proc { |ability,user,target,move,mults,baseDmg,type| if target.hp==target.totalhp - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.5).round + mults[FINAL_DMG_MULT] /= 2 end } ) @@ -1218,7 +1216,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:MULTISCALE, BattleHandlers::DamageCalcTargetAbility.add(:THICKFAT, proc { |ability,user,target,move,mults,baseDmg,type| if isConst?(type,PBTypes,:FIRE) || isConst?(type,PBTypes,:ICE) - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*0.5).round + mults[BASE_DMG_MULT] /= 2 end } ) @@ -1226,7 +1224,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:THICKFAT, BattleHandlers::DamageCalcTargetAbility.add(:WATERBUBBLE, proc { |ability,user,target,move,mults,baseDmg,type| if isConst?(type,PBTypes,:FIRE) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.5).round + mults[FINAL_DMG_MULT] /= 2 end } ) @@ -1238,7 +1236,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:WATERBUBBLE, BattleHandlers::DamageCalcTargetAbilityNonIgnorable.add(:PRISMARMOR, proc { |ability,user,target,move,mults,baseDmg,type| if PBTypes.superEffective?(target.damageState.typeMod) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.75).round + mults[FINAL_DMG_MULT] *= 0.75 end } ) @@ -1246,7 +1244,7 @@ BattleHandlers::DamageCalcTargetAbilityNonIgnorable.add(:PRISMARMOR, BattleHandlers::DamageCalcTargetAbilityNonIgnorable.add(:SHADOWSHIELD, proc { |ability,user,target,move,mults,baseDmg,type| if target.hp==target.totalhp - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.5).round + mults[FINAL_DMG_MULT] /= 2 end } ) @@ -1259,14 +1257,14 @@ BattleHandlers::DamageCalcTargetAllyAbility.add(:FLOWERGIFT, proc { |ability,user,target,move,mults,baseDmg,type| w = user.battle.pbWeather if move.specialMove? && (w==PBWeather::Sun || w==PBWeather::HarshSun) - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round + mults[DEF_MULT] *= 1.5 end } ) BattleHandlers::DamageCalcTargetAllyAbility.add(:FRIENDGUARD, proc { |ability,user,target,move,mults,baseDmg,type| - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*0.75).round + mults[FINAL_DMG_MULT] *= 0.75 } ) diff --git a/Data/Scripts/012_Battle/008_BattleHandlers_Items.rb b/Data/Scripts/012_Battle/008_BattleHandlers_Items.rb index edd3ff257..541d16c79 100644 --- a/Data/Scripts/012_Battle/008_BattleHandlers_Items.rb +++ b/Data/Scripts/012_Battle/008_BattleHandlers_Items.rb @@ -4,7 +4,7 @@ BattleHandlers::SpeedCalcItem.add(:CHOICESCARF, proc { |item,battler,mult| - next (mult*1.5).round + next mult*1.5 } ) @@ -414,7 +414,7 @@ BattleHandlers::PriorityBracketUseItem.add(:QUICKCLAW, BattleHandlers::AccuracyCalcUserItem.add(:WIDELENS, proc { |item,mods,user,target,move,type| - mods[ACC_MULT] = (mods[ACC_MULT]*1.1).round + mods[ACC_MULT] *= 1.1 } ) @@ -423,7 +423,7 @@ BattleHandlers::AccuracyCalcUserItem.add(:ZOOMLENS, if (target.battle.choices[target.index][0]!=:UseMove && target.battle.choices[target.index][0]!=:Shift) || target.movedThisRound? - mods[ACC_MULT] = (mods[ACC_MULT]*1.2).round + mods[ACC_MULT] *= 1.2 end } ) @@ -434,7 +434,7 @@ BattleHandlers::AccuracyCalcUserItem.add(:ZOOMLENS, BattleHandlers::AccuracyCalcTargetItem.add(:BRIGHTPOWDER, proc { |item,mods,user,target,move,type| - mods[ACC_MULT] = (mods[ACC_MULT]*0.9).round + mods[ACC_MULT] *= 0.9 } ) @@ -448,14 +448,14 @@ BattleHandlers::DamageCalcUserItem.add(:ADAMANTORB, proc { |item,user,target,move,mults,baseDmg,type| if user.isSpecies?(:DIALGA) && (isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:STEEL)) - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round + mults[BASE_DMG_MULT] *= 1.2 end } ) BattleHandlers::DamageCalcUserItem.add(:BLACKBELT, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:FIGHTING) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FIGHTING) } ) @@ -463,7 +463,7 @@ BattleHandlers::DamageCalcUserItem.copy(:BLACKBELT,:FISTPLATE) BattleHandlers::DamageCalcUserItem.add(:BLACKGLASSES, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:DARK) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:DARK) } ) @@ -477,7 +477,7 @@ BattleHandlers::DamageCalcUserItem.add(:BUGGEM, BattleHandlers::DamageCalcUserItem.add(:CHARCOAL, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:FIRE) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FIRE) } ) @@ -485,13 +485,13 @@ BattleHandlers::DamageCalcUserItem.copy(:CHARCOAL,:FLAMEPLATE) BattleHandlers::DamageCalcUserItem.add(:CHOICEBAND, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round if move.physicalMove? + mults[BASE_DMG_MULT] *= 1.5 if move.physicalMove? } ) BattleHandlers::DamageCalcUserItem.add(:CHOICESPECS, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.5).round if move.specialMove? + mults[BASE_DMG_MULT] *= 1.5 if move.specialMove? } ) @@ -511,7 +511,7 @@ BattleHandlers::DamageCalcUserItem.add(:DEEPSEATOOTH, BattleHandlers::DamageCalcUserItem.add(:DRAGONFANG, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:DRAGON) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:DRAGON) } ) @@ -532,7 +532,7 @@ BattleHandlers::DamageCalcUserItem.add(:ELECTRICGEM, BattleHandlers::DamageCalcUserItem.add(:EXPERTBELT, proc { |item,user,target,move,mults,baseDmg,type| if PBTypes.superEffective?(target.damageState.typeMod) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*1.2).round + mults[FINAL_DMG_MULT] *= 1.2 end } ) @@ -577,7 +577,7 @@ BattleHandlers::DamageCalcUserItem.add(:GRISEOUSORB, proc { |item,user,target,move,mults,baseDmg,type| if user.isSpecies?(:GIRATINA) && (isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:GHOST)) - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round + mults[BASE_DMG_MULT] *= 1.2 end } ) @@ -590,7 +590,7 @@ BattleHandlers::DamageCalcUserItem.add(:GROUNDGEM, BattleHandlers::DamageCalcUserItem.add(:HARDSTONE, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:ROCK) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:ROCK) } ) @@ -605,7 +605,7 @@ BattleHandlers::DamageCalcUserItem.add(:ICEGEM, BattleHandlers::DamageCalcUserItem.add(:LIFEORB, proc { |item,user,target,move,mults,baseDmg,type| if !move.is_a?(PokeBattle_Confusion) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*1.3).round + mults[FINAL_DMG_MULT] *= 1.3 end } ) @@ -622,14 +622,14 @@ BattleHandlers::DamageCalcUserItem.add(:LUSTROUSORB, proc { |item,user,target,move,mults,baseDmg,type| if user.isSpecies?(:PALKIA) && (isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:WATER)) - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round + mults[BASE_DMG_MULT] *= 1.2 end } ) BattleHandlers::DamageCalcUserItem.add(:MAGNET, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:ELECTRIC) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:ELECTRIC) } ) @@ -637,7 +637,7 @@ BattleHandlers::DamageCalcUserItem.copy(:MAGNET,:ZAPPLATE) BattleHandlers::DamageCalcUserItem.add(:METALCOAT, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:STEEL) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:STEEL) } ) @@ -646,13 +646,13 @@ BattleHandlers::DamageCalcUserItem.copy(:METALCOAT,:IRONPLATE) BattleHandlers::DamageCalcUserItem.add(:METRONOME, proc { |item,user,target,move,mults,baseDmg,type| met = 1+0.2*[user.effects[PBEffects::Metronome],5].min - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*met).round + mults[FINAL_DMG_MULT] *= met } ) BattleHandlers::DamageCalcUserItem.add(:MIRACLESEED, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:GRASS) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:GRASS) } ) @@ -660,13 +660,13 @@ BattleHandlers::DamageCalcUserItem.copy(:MIRACLESEED,:MEADOWPLATE,:ROSEINCENSE) BattleHandlers::DamageCalcUserItem.add(:MUSCLEBAND, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.1).round if move.physicalMove? + mults[BASE_DMG_MULT] *= 1.1 if move.physicalMove? } ) BattleHandlers::DamageCalcUserItem.add(:MYSTICWATER, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:WATER) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:WATER) } ) @@ -674,7 +674,7 @@ BattleHandlers::DamageCalcUserItem.copy(:MYSTICWATER,:SPLASHPLATE,:SEAINCENSE,:W BattleHandlers::DamageCalcUserItem.add(:NEVERMELTICE, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:ICE) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:ICE) } ) @@ -688,13 +688,13 @@ BattleHandlers::DamageCalcUserItem.add(:NORMALGEM, BattleHandlers::DamageCalcUserItem.add(:PIXIEPLATE, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:FAIRY) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FAIRY) } ) BattleHandlers::DamageCalcUserItem.add(:POISONBARB, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:POISON) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:POISON) } ) @@ -720,7 +720,7 @@ BattleHandlers::DamageCalcUserItem.add(:ROCKGEM, BattleHandlers::DamageCalcUserItem.add(:SHARPBEAK, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:FLYING) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FLYING) } ) @@ -728,13 +728,13 @@ BattleHandlers::DamageCalcUserItem.copy(:SHARPBEAK,:SKYPLATE) BattleHandlers::DamageCalcUserItem.add(:SILKSCARF, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:NORMAL) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:NORMAL) } ) BattleHandlers::DamageCalcUserItem.add(:SILVERPOWDER, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:BUG) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:BUG) } ) @@ -742,7 +742,7 @@ BattleHandlers::DamageCalcUserItem.copy(:SILVERPOWDER,:INSECTPLATE) BattleHandlers::DamageCalcUserItem.add(:SOFTSAND, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:GROUND) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:GROUND) } ) @@ -753,11 +753,11 @@ BattleHandlers::DamageCalcUserItem.add(:SOULDEW, next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS) if NEWEST_BATTLE_MECHANICS if isConst?(type,PBTypes,:PSYCHIC) || isConst?(type,PBTypes,:DRAGON) - mults[FINAL_DMG_MULT] = (mults[FINAL_DMG_MULT]*1.2).round + mults[FINAL_DMG_MULT] *= 1.2 end else if move.specialMove? && !user.battle.rules["souldewclause"] - mults[ATK_MULT] = (mults[ATK_MULT]*1.5).round + mults[ATK_MULT] *= 1.5 end end } @@ -765,7 +765,7 @@ BattleHandlers::DamageCalcUserItem.add(:SOULDEW, BattleHandlers::DamageCalcUserItem.add(:SPELLTAG, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:GHOST) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:GHOST) } ) @@ -787,7 +787,7 @@ BattleHandlers::DamageCalcUserItem.add(:THICKCLUB, BattleHandlers::DamageCalcUserItem.add(:TWISTEDSPOON, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.2).round if isConst?(type,PBTypes,:PSYCHIC) + mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:PSYCHIC) } ) @@ -801,7 +801,7 @@ BattleHandlers::DamageCalcUserItem.add(:WATERGEM, BattleHandlers::DamageCalcUserItem.add(:WISEGLASSES, proc { |item,user,target,move,mults,baseDmg,type| - mults[BASE_DMG_MULT] = (mults[BASE_DMG_MULT]*1.1).round if move.specialMove? + mults[BASE_DMG_MULT] *= 1.1 if move.specialMove? } ) @@ -814,7 +814,7 @@ BattleHandlers::DamageCalcUserItem.add(:WISEGLASSES, BattleHandlers::DamageCalcTargetItem.add(:ASSAULTVEST, proc { |item,user,target,move,mults,baseDmg,type| - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round if move.specialMove? + mults[DEF_MULT] *= 1.5 if move.specialMove? } ) @@ -869,7 +869,7 @@ BattleHandlers::DamageCalcTargetItem.add(:EVIOLITE, # evolve even if the species generally can, and such forms are not # affected by Eviolite. evos = pbGetEvolvedFormData(target.pokemon.fSpecies,true) - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round if evos && evos.length>0 + mults[DEF_MULT] *= 1.5 if evos && evos.length>0 } ) @@ -894,7 +894,7 @@ BattleHandlers::DamageCalcTargetItem.add(:KEBIABERRY, BattleHandlers::DamageCalcTargetItem.add(:METALPOWDER, proc { |item,user,target,move,mults,baseDmg,type| if target.isSpecies?(:DITTO) && !target.effects[PBEffects::Transform] - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round + mults[DEF_MULT] *= 1.5 end } ) @@ -940,7 +940,7 @@ BattleHandlers::DamageCalcTargetItem.add(:SOULDEW, next if NEWEST_BATTLE_MECHANICS next if !target.isSpecies?(:LATIAS) && !target.isSpecies?(:LATIOS) if move.specialMove? && !user.battle.rules["souldewclause"] - mults[DEF_MULT] = (mults[DEF_MULT]*1.5).round + mults[DEF_MULT] *= 1.5 end } ) From c73906170a7de751d5fdd64992cc3f629a972de3 Mon Sep 17 00:00:00 2001 From: jonisavo Date: Sun, 20 Sep 2020 20:55:51 +0300 Subject: [PATCH 02/12] Rename PokeBattle_Pokemon to Pokemon Deprecate PokeBattle_Pokemon and pbNewPkmn --- Data/Scripts/011_Data/003_PBMove.rb | 2 +- .../004_Battle_ExpAndMoveLearning.rb | 8 ++-- .../005_Battle scene/008_Scene_Commands.rb | 2 +- .../013_Overworld/006_PField_Battles.rb | 2 +- .../009_PField_RoamingPokemon.rb | 2 +- .../014_Trainers/002_PTrainer_NPCTrainers.rb | 4 +- Data/Scripts/015_Items/001_PItem_Items.rb | 16 ++++---- ...1_PokeBattle_Pokemon.rb => 001_Pokemon.rb} | 41 +++++++++++-------- Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb | 2 +- .../016_Pokemon/003_Pokemon_MegaEvolution.rb | 4 +- .../016_Pokemon/004_Pokemon_ShadowPokemon.rb | 14 +++---- .../016_Pokemon/006_Pokemon_Chatter.rb | 2 +- .../016_Pokemon/008_Pokemon_Storage.rb | 2 +- Data/Scripts/017_UI/006_PScreen_Summary.rb | 2 +- .../Scripts/017_UI/020_PScreen_EggHatching.rb | 4 +- Data/Scripts/017_UI/022_PScreen_Trading.rb | 2 +- .../017_UI/024_PScreen_PurifyChamber.rb | 12 +++--- .../003_PBattle_OrgBattle.rb | 2 +- .../004_PBattle_OrgBattleRules.rb | 8 ++-- .../003_PSystem_FileUtilities.rb | 2 +- .../004_PSystem_PokemonUtilities.rb | 6 +-- Data/Scripts/021_Debug/003_Debug_Pokemon.rb | 26 ++++++------ Data/Scripts/021_Debug/004_Editor_Screens.rb | 6 +-- .../Scripts/021_Debug/006_Editor_DataTypes.rb | 4 +- Data/Scripts/022_Compiler/002_Compiler_PBS.rb | 24 +++++------ 25 files changed, 102 insertions(+), 97 deletions(-) rename Data/Scripts/016_Pokemon/{001_PokeBattle_Pokemon.rb => 001_Pokemon.rb} (97%) diff --git a/Data/Scripts/011_Data/003_PBMove.rb b/Data/Scripts/011_Data/003_PBMove.rb index 7e0b3f3fd..ba026c502 100644 --- a/Data/Scripts/011_Data/003_PBMove.rb +++ b/Data/Scripts/011_Data/003_PBMove.rb @@ -45,7 +45,7 @@ def pbClearData end #=============================================================================== -# Move objects known by PokeBattle_Pokemon. +# Move objects known by Pokémon. #=============================================================================== class PBMove attr_reader(:id) # This move's ID diff --git a/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb b/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb index b7e6511cc..7dc1b83d4 100644 --- a/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb +++ b/Data/Scripts/012_Battle/003_Battle/004_Battle_ExpAndMoveLearning.rb @@ -75,12 +75,12 @@ class PokeBattle_Battle PBStats.eachStat do |s| evGain = evYield[s] # Can't exceed overall limit - if evTotal+evGain>PokeBattle_Pokemon::EV_LIMIT - evGain = PokeBattle_Pokemon::EV_LIMIT-evTotal + if evTotal+evGain>Pokemon::EV_LIMIT + evGain = Pokemon::EV_LIMIT-evTotal end # Can't exceed individual stat limit - if pkmn.ev[s]+evGain>PokeBattle_Pokemon::EV_STAT_LIMIT - evGain = PokeBattle_Pokemon::EV_STAT_LIMIT-pkmn.ev[s] + if pkmn.ev[s]+evGain>Pokemon::EV_STAT_LIMIT + evGain = Pokemon::EV_STAT_LIMIT-pkmn.ev[s] end # Add EV gain pkmn.ev[s] += evGain diff --git a/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb b/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb index e438dac1c..14ec36425 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb @@ -450,7 +450,7 @@ class PokeBattle_Scene # Opens the nicknaming screen for a newly caught Pokémon #============================================================================= def pbNameEntry(helpText,pkmn) - return pbEnterPokemonName(helpText,0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,"",pkmn) + return pbEnterPokemonName(helpText, 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pkmn) end #============================================================================= diff --git a/Data/Scripts/013_Overworld/006_PField_Battles.rb b/Data/Scripts/013_Overworld/006_PField_Battles.rb index 87b40282c..959cfe28f 100644 --- a/Data/Scripts/013_Overworld/006_PField_Battles.rb +++ b/Data/Scripts/013_Overworld/006_PField_Battles.rb @@ -231,7 +231,7 @@ def pbWildBattleCore(*args) foeParty = [] sp = nil for arg in args - if arg.is_a?(PokeBattle_Pokemon) + if arg.is_a?(Pokemon) foeParty.push(arg) elsif arg.is_a?(Array) species = getID(PBSpecies,arg[0]) diff --git a/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb b/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb index 8750f930d..c869d3064 100644 --- a/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb +++ b/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb @@ -220,7 +220,7 @@ def pbRoamingPokemonBattle(species, level) # level if it doesn't already exist idxRoamer = $PokemonTemp.roamerIndex if !$PokemonGlobal.roamPokemon[idxRoamer] || - !$PokemonGlobal.roamPokemon[idxRoamer].is_a?(PokeBattle_Pokemon) + !$PokemonGlobal.roamPokemon[idxRoamer].is_a?(Pokemon) $PokemonGlobal.roamPokemon[idxRoamer] = pbGenerateWildPokemon(species,level,true) end # Set some battle rules diff --git a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb index 3aff3bfc7..93a7a4196 100644 --- a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb +++ b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb @@ -99,12 +99,12 @@ def pbLoadTrainer(trainerid,trainername,partyid=0) if poke[TPIV] && poke[TPIV].length>0 pokemon.iv[i] = (i0 pokemon.ev[i] = (iPokeBattle_Pokemon::EV_LIMIT - evgain = PokeBattle_Pokemon::EV_LIMIT-totalev + if totalev+evgain>Pokemon::EV_LIMIT + evgain = Pokemon::EV_LIMIT-totalev end - if pkmn.ev[ev]+evgain>PokeBattle_Pokemon::EV_STAT_LIMIT - evgain = PokeBattle_Pokemon::EV_STAT_LIMIT-pkmn.ev[ev] + if pkmn.ev[ev]+evgain>Pokemon::EV_STAT_LIMIT + evgain = Pokemon::EV_STAT_LIMIT-pkmn.ev[ev] end if evgain>0 pkmn.ev[ev] += evgain @@ -503,11 +503,11 @@ def pbRaiseEffortValues(pkmn,ev,evgain=10,evlimit=true) for i in 0...6 totalev += pkmn.ev[i] end - if totalev+evgain>PokeBattle_Pokemon::EV_LIMIT - evgain = PokeBattle_Pokemon::EV_LIMIT-totalev + if totalev+evgain>Pokemon::EV_LIMIT + evgain = Pokemon::EV_LIMIT-totalev end - if pkmn.ev[ev]+evgain>PokeBattle_Pokemon::EV_STAT_LIMIT - evgain = PokeBattle_Pokemon::EV_STAT_LIMIT-pkmn.ev[ev] + if pkmn.ev[ev]+evgain>Pokemon::EV_STAT_LIMIT + evgain = Pokemon::EV_STAT_LIMIT-pkmn.ev[ev] end if evlimit && pkmn.ev[ev]+evgain>100 evgain = 100-pkmn.ev[ev] diff --git a/Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb similarity index 97% rename from Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb rename to Data/Scripts/016_Pokemon/001_Pokemon.rb index 283cebbbd..88c76a4c0 100644 --- a/Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -2,7 +2,7 @@ # Instances of this class are individual Pokémon. # The player's party Pokémon are stored in the array $Trainer.party. #=============================================================================== -class PokeBattle_Pokemon +class Pokemon # @return [String] the nickname of this Pokémon attr_accessor :name # @return [Integer] this Pokémon's national Pokédex number @@ -55,7 +55,7 @@ class PokeBattle_Pokemon attr_reader :statusCount # Another Pokémon which has been fused with this Pokémon (or nil if there is none). # Currently only used by Kyurem, to record a fused Reshiram or Zekrom. - # @return [PokeBattle_Pokemon, nil] the Pokémon fused into this one (nil if there is none) + # @return [Pokemon, nil] the Pokémon fused into this one (nil if there is none) attr_accessor :fused # @return [Array] an array of IV values for HP, Atk, Def, Speed, Sp. Atk and Sp. Def attr_accessor :iv @@ -780,7 +780,7 @@ class PokeBattle_Pokemon #============================================================================= # Sets this Pokémon's status. See {PBStatuses} for all possible status effects. - # @param new_status [Integer, Symbol, String] status to set (from PBStatuses) + # @param value [Integer, Symbol, String] status to set (from {PBStatuses}) def status=(value) new_status = getID(PBStatuses, value) if !new_status @@ -1044,7 +1044,7 @@ class PokeBattle_Pokemon #============================================================================= # Creates a copy of this Pokémon and returns it. - # @return [PokeBattle_Pokemon] a copy of this Pokémon + # @return [Pokemon] a copy of this Pokémon def clone ret = super ret.iv = @iv.clone @@ -1059,9 +1059,9 @@ class PokeBattle_Pokemon # Creates a new Pokémon object. # @param species [Integer, Symbol, String] Pokémon species # @param level [Integer] Pokémon level - # @param player [PokeBattle_Trainer] object for the original trainer + # @param owner [PokeBattle_Trainer] object for the original trainer # @param withMoves [Boolean] whether the Pokémon should have moves - def initialize(species, level, player = nil, withMoves = true) + def initialize(species, level, owner = nil, withMoves = true) ospecies = species.to_s species = getID(PBSpecies, species) cname = getConstantName(PBSpecies, species) rescue nil @@ -1090,11 +1090,11 @@ class PokeBattle_Pokemon @ribbons = [] @ballused = 0 @eggsteps = 0 - if player - @trainerID = player.id - @ot = player.name - @otgender = player.gender - @language = player.language + if owner + @trainerID = owner.id + @ot = owner.name + @otgender = owner.gender + @language = owner.language else @trainerID = 0 @ot = "" @@ -1122,16 +1122,21 @@ class PokeBattle_Pokemon end #=============================================================================== -# +# Deprecated classes & methods #=============================================================================== -# Creates a new Pokémon object. -# @param species [Integer, Symbol, String] Pokémon species -# @param level [Integer] Pokémon level -# @param owner [PokeBattle_Trainer] object for the original trainer -# @param withMoves [Boolean] whether the Pokémon should have moves +# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias +# and is slated to be removed in vXX. +class PokeBattle_Pokemon; end + +PokeBattle_Pokemon = Pokemon + +# (see Pokemon#initialize) +# @deprecated Use +Pokemon.new+ instead. This method and its aliases are +# slated to be removed in vXX. def pbNewPkmn(species, level, owner = $Trainer, withMoves = true) - return PokeBattle_Pokemon.new(species, level, owner, withMoves) + Kernel.echoln("WARN: pbNewPkmn and its aliases are deprecated and slated to be removed in Essentials vXX") + return Pokemon.new(species, level, owner, withMoves) end alias pbGenPkmn pbNewPkmn alias pbGenPoke pbNewPkmn diff --git a/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb b/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb index ecada1c63..c70952686 100644 --- a/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb +++ b/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb @@ -1,4 +1,4 @@ -class PokeBattle_Pokemon +class Pokemon attr_accessor :formTime # Time when Furfrou's/Hoopa's form was set attr_accessor :forcedForm diff --git a/Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb b/Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb index 2fd26d52f..32d1f744f 100644 --- a/Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb +++ b/Data/Scripts/016_Pokemon/003_Pokemon_MegaEvolution.rb @@ -2,7 +2,7 @@ # Mega Evolution # NOTE: These are treated as form changes in Essentials. #=============================================================================== -class PokeBattle_Pokemon +class Pokemon def getMegaForm(checkItemOnly=false) formData = pbLoadFormToSpecies return 0 if !formData[@species] || formData[@species].length==0 @@ -68,7 +68,7 @@ end # Primal Reversion # NOTE: These are treated as form changes in Essentials. #=============================================================================== -class PokeBattle_Pokemon +class Pokemon def hasPrimalForm? v = MultipleForms.call("getPrimalForm",self) return v!=nil diff --git a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb b/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb index a41b3f8cf..13bd3433d 100644 --- a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb +++ b/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb @@ -54,7 +54,7 @@ def pbPurify(pokemon,scene) speciesname = PBSpecies.getName(pokemon.species) if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?",speciesname)) newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), - 0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,"",pokemon) + 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pokemon) pokemon.name = newname if newname!="" end end @@ -64,11 +64,11 @@ def pbApplyEVGain(pokemon,ev,evgain) for i in 0...6 totalev += pokemon.ev[i] end - if totalev+evgain>PokeBattle_Pokemon::EV_LIMIT # Can't exceed overall limit - evgain -= totalev+evgain-PokeBattle_Pokemon::EV_LIMIT + if totalev+evgain>Pokemon::EV_LIMIT # Can't exceed overall limit + evgain -= totalev+evgain-Pokemon::EV_LIMIT end - if pokemon.ev[ev]+evgain>PokeBattle_Pokemon::EV_STAT_LIMIT - evgain -= totalev+evgain-PokeBattle_Pokemon::EV_STAT_LIMIT + if pokemon.ev[ev]+evgain>Pokemon::EV_STAT_LIMIT + evgain -= totalev+evgain-Pokemon::EV_STAT_LIMIT end if evgain>0 pokemon.ev[ev] += evgain @@ -231,7 +231,7 @@ end #=============================================================================== # Pokémon class. #=============================================================================== -class PokeBattle_Pokemon +class Pokemon attr_writer :heartgauge attr_accessor :shadow attr_writer :hypermode @@ -398,7 +398,7 @@ class PokeBattle_Battler def pbHyperMode return if fainted? || !shadowPokemon? || inHyperMode? p = self.pokemon - if @battle.pbRandom(p.heartgauge)<=PokeBattle_Pokemon::HEARTGAUGESIZE/4 + if @battle.pbRandom(p.heartgauge)<=Pokemon::HEARTGAUGESIZE/4 p.hypermode = true @battle.pbDisplay(_INTL("{1}'s emotions rose to a fever pitch!\nIt entered Hyper Mode!",self.pbThis)) end diff --git a/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb b/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb index d50e8671f..779b79045 100644 --- a/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb +++ b/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb @@ -1,4 +1,4 @@ -class PokeBattle_Pokemon +class Pokemon attr_accessor :chatter end diff --git a/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb b/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb index 04e40fc4c..0b2c49786 100644 --- a/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb +++ b/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb @@ -148,7 +148,7 @@ class PokemonStorage return (x==-1) ? self.party : @boxes[x] else for i in @boxes - raise "Box is a Pokémon, not a box" if i.is_a?(PokeBattle_Pokemon) + raise "Box is a Pokémon, not a box" if i.is_a?(Pokemon) end return (x==-1) ? self.party[y] : @boxes[x][y] end diff --git a/Data/Scripts/017_UI/006_PScreen_Summary.rb b/Data/Scripts/017_UI/006_PScreen_Summary.rb index fa9e861c5..463e1f085 100644 --- a/Data/Scripts/017_UI/006_PScreen_Summary.rb +++ b/Data/Scripts/017_UI/006_PScreen_Summary.rb @@ -362,7 +362,7 @@ class PokemonSummary_Scene dexNumShadow = (@pokemon.shiny?) ? Color.new(224,152,144) : Color.new(176,176,176) # If a Shadow Pokémon, draw the heart gauge area and bar if @pokemon.shadowPokemon? - shadowfract = @pokemon.heartgauge*1.0/PokeBattle_Pokemon::HEARTGAUGESIZE + shadowfract = @pokemon.heartgauge*1.0/Pokemon::HEARTGAUGESIZE imagepos = [ ["Graphics/Pictures/Summary/overlay_shadow",224,240], ["Graphics/Pictures/Summary/overlay_shadowbar",242,280,0,0,(shadowfract*248).floor,-1] diff --git a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb index b3714b32c..ebfea00d9 100644 --- a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb +++ b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb @@ -109,7 +109,7 @@ class PokemonEggHatch_Scene if pbConfirmMessage( _INTL("Would you like to nickname the newly hatched {1}?",@pokemon.name)) { update } nickname=pbEnterPokemonName(_INTL("{1}'s nickname?",@pokemon.name), - 0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,"",@pokemon,true) + 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", @pokemon, true) @pokemon.name=nickname if nickname!="" @nicknamed=true end @@ -209,7 +209,7 @@ def pbHatch(pokemon) pbMessage(_INTL("{1} hatched from the Egg!",speciesname)) if pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?",speciesname)) nickname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), - 0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,"",pokemon) + 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pokemon) pokemon.name = nickname if nickname!="" end end diff --git a/Data/Scripts/017_UI/022_PScreen_Trading.rb b/Data/Scripts/017_UI/022_PScreen_Trading.rb index 55ae16dea..059d269ea 100644 --- a/Data/Scripts/017_UI/022_PScreen_Trading.rb +++ b/Data/Scripts/017_UI/022_PScreen_Trading.rb @@ -194,7 +194,7 @@ def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) opponent = PokeBattle_Trainer.new(trainerName,trainerGender) opponent.setForeignID($Trainer) yourPokemon = nil; resetmoves = true - if newpoke.is_a?(PokeBattle_Pokemon) + if newpoke.is_a?(Pokemon) newpoke.trainerID = opponent.id newpoke.ot = opponent.name newpoke.otgender = opponent.gender diff --git a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb index 941819788..a06830d2f 100644 --- a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb +++ b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb @@ -676,9 +676,9 @@ class Window_PurifyChamberSets < Window_DrawableCommand Color.new(0,0,256),@chamber[index].tempo,PurifyChamber.maximumTempo()) end if @chamber.getShadow(index) - pbDrawGauge(self.contents,Rect.new(rect.x+16,rect.y+18,48,8), - Color.new(192,0,256),@chamber.getShadow(index).heartgauge, - PokeBattle_Pokemon::HEARTGAUGESIZE) + pbDrawGauge(self.contents, Rect.new(rect.x+16,rect.y+18,48,8), + Color.new(192,0,256), @chamber.getShadow(index).heartgauge, + Pokemon::HEARTGAUGESIZE) end pbDrawTextPositions(self.contents,textpos) end @@ -964,9 +964,9 @@ class PurifyChamberSetView < SpriteWrapper textpos.push([_INTL("FLOW"),2+@info.bitmap.width/2,24,0, Color.new(248,248,248),Color.new(128,128,128)]) # draw heart gauge - pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8), - Color.new(192,0,256),pkmn.heartgauge, - PokeBattle_Pokemon::HEARTGAUGESIZE) + pbDrawGauge(@info.bitmap, Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8), + Color.new(192,0,256), pkmn.heartgauge, + Pokemon::HEARTGAUGESIZE) # draw flow gauge pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,24+8,@info.bitmap.width*1/4,8), Color.new(0,0,248),@chamber.chamberFlow(@set),6) diff --git a/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb b/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb index cc846814b..e767e51e5 100644 --- a/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb +++ b/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb @@ -175,7 +175,7 @@ class PBPokemon for i in 0...6 evcount+=1 if ((@ev&(1<(maxHeightInMeters*10).round end def pbTooHeavy?(pkmn,maxWeightInKg) - species = (pkmn.is_a?(PokeBattle_Pokemon)) ? pkmn.species : pkmn - form = (pkmn.is_a?(PokeBattle_Pokemon)) ? pkmn.form : 0 + species = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn + form = (pkmn.is_a?(Pokemon)) ? pkmn.form : 0 weight = pbGetSpeciesData(species,form,SpeciesWeight) return weight>(maxWeightInKg*10).round end diff --git a/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb b/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb index 95f8f968c..7f45d85a6 100644 --- a/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb +++ b/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb @@ -459,7 +459,7 @@ def pbPlayCry(pokemon,volume=90,pitch=nil) return if !pokemon if pokemon.is_a?(Numeric) || pokemon.is_a?(String) || pokemon.is_a?(Symbol) pbPlayCrySpecies(pokemon,0,volume,pitch) - elsif pokemon.is_a?(PokeBattle_Pokemon) + elsif pokemon.is_a?(Pokemon) pbPlayCryPokemon(pokemon,volume,pitch) end end diff --git a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb index 725f808e0..377bcb1ab 100644 --- a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb +++ b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb @@ -9,7 +9,7 @@ def pbNickname(pokemon) speciesname = PBSpecies.getName(pokemon.species) if pbConfirmMessage(_INTL("Would you like to give a nickname to {1}?",speciesname)) helptext = _INTL("{1}'s nickname?",speciesname) - newname = pbEnterPokemonName(helptext,0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,"",pokemon) + newname = pbEnterPokemonName(helptext, 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pokemon) pokemon.name = newname if newname!="" end end @@ -146,7 +146,7 @@ def pbAddForeignPokemon(pokemon,level=nil,ownerName=nil,nickname=nil,ownerGender pokemon.otgender = ownerGender end # Set nickname - pokemon.name = nickname[0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE] if nickname && nickname!="" + pokemon.name = nickname[0, Pokemon::MAX_POKEMON_NAME_SIZE] if nickname && nickname!="" # Recalculate stats pokemon.calcStats if ownerName @@ -206,7 +206,7 @@ end def pbSeenForm(pkmn,gender=0,form=0) $Trainer.formseen = [] if !$Trainer.formseen $Trainer.formlastseen = [] if !$Trainer.formlastseen - if pkmn.is_a?(PokeBattle_Pokemon) + if pkmn.is_a?(Pokemon) gender = pkmn.gender form = (pkmn.form rescue 0) species = pkmn.species diff --git a/Data/Scripts/021_Debug/003_Debug_Pokemon.rb b/Data/Scripts/021_Debug/003_Debug_Pokemon.rb index 4bb29341b..52579bbe7 100644 --- a/Data/Scripts/021_Debug/003_Debug_Pokemon.rb +++ b/Data/Scripts/021_Debug/003_Debug_Pokemon.rb @@ -218,8 +218,8 @@ module PokemonDebugMixin evcommands.push(_INTL("Randomise all")) evcommands.push(_INTL("Max randomise all")) cmd2 = pbShowCommands(_INTL("Change which EV?\nTotal: {1}/{2} ({3}%)", - totalev,PokeBattle_Pokemon::EV_LIMIT, - 100*totalev/PokeBattle_Pokemon::EV_LIMIT),evcommands,cmd2) + totalev, Pokemon::EV_LIMIT, + 100*totalev/Pokemon::EV_LIMIT), evcommands, cmd2) break if cmd2<0 if cmd20 r = rand(numstats) - next if pkmn.ev[r]>=PokeBattle_Pokemon::EV_STAT_LIMIT - addVal = 1+rand(PokeBattle_Pokemon::EV_STAT_LIMIT/4) + next if pkmn.ev[r]>=Pokemon::EV_STAT_LIMIT + addVal = 1+rand(Pokemon::EV_STAT_LIMIT/4) addVal = evTotalTarget if addVal>evTotalTarget - addVal = [addVal,PokeBattle_Pokemon::EV_STAT_LIMIT-pkmn.ev[r]].min + addVal = [addVal, Pokemon::EV_STAT_LIMIT-pkmn.ev[r]].min next if addVal==0 pkmn.ev[r] += addVal evTotalTarget -= addVal @@ -292,7 +292,7 @@ module PokemonDebugMixin end elsif cmd2==ivcommands.length-1 # Randomise for i in 0...numstats - pkmn.iv[i] = rand(PokeBattle_Pokemon::IV_STAT_LIMIT+1) + pkmn.iv[i] = rand(Pokemon::IV_STAT_LIMIT+1) end pkmn.calcStats pbRefreshSingle(pkmnid) @@ -601,7 +601,7 @@ module PokemonDebugMixin when 0 # Rename oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : "" newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), - 0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,oldname,pkmn) + 0, Pokemon::MAX_POKEMON_NAME_SIZE, oldname, pkmn) if newname && newname!="" pkmn.name = newname pbRefreshSingle(pkmnid) @@ -759,10 +759,10 @@ module PokemonDebugMixin if pkmn.shadowPokemon? oldheart = pkmn.heartgauge params = ChooseNumberParams.new - params.setRange(0,PokeBattle_Pokemon::HEARTGAUGESIZE) + params.setRange(0, Pokemon::HEARTGAUGESIZE) params.setDefaultValue(pkmn.heartgauge) val = pbMessageChooseNumber( - _INTL("Set the heart gauge (max. {1}).",PokeBattle_Pokemon::HEARTGAUGESIZE), + _INTL("Set the heart gauge (max. {1}).", Pokemon::HEARTGAUGESIZE), params) { pbUpdate } if val!=oldheart pkmn.adjustHeart(val-oldheart) diff --git a/Data/Scripts/021_Debug/004_Editor_Screens.rb b/Data/Scripts/021_Debug/004_Editor_Screens.rb index 8f0410600..23ef33eb8 100644 --- a/Data/Scripts/021_Debug/004_Editor_Screens.rb +++ b/Data/Scripts/021_Debug/004_Editor_Screens.rb @@ -514,12 +514,12 @@ module TrainerPokemonProperty [_INTL("Form"),LimitProperty2.new(999),_INTL("Form of the Pokémon.")], [_INTL("Shiny"),BooleanProperty2,_INTL("If set to true, the Pokémon is a different-colored Pokémon.")], [_INTL("Nature"),NatureProperty,_INTL("Nature of the Pokémon.")], - [_INTL("IVs"),IVsProperty.new(PokeBattle_Pokemon::IV_STAT_LIMIT),_INTL("Individual values for each of the Pokémon's stats.")], + [_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")], [_INTL("Happiness"),LimitProperty2.new(255),_INTL("Happiness of the Pokémon (0-255).")], [_INTL("Nickname"),StringProperty,_INTL("Name of the Pokémon.")], [_INTL("Shadow"),BooleanProperty2,_INTL("If set to true, the Pokémon is a Shadow Pokémon.")], [_INTL("Ball"),BallProperty.new(oldsetting),_INTL("The kind of Poké Ball the Pokémon is kept in.")], - [_INTL("EVs"),EVsProperty.new(PokeBattle_Pokemon::EV_STAT_LIMIT),_INTL("Effort values for each of the Pokémon's stats.")] + [_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")] ] pbPropertyList(settingname,oldsetting,properties,false) return nil if !oldsetting[TPSPECIES] || oldsetting[TPSPECIES]==0 @@ -741,7 +741,7 @@ def pbPokemonEditor metrics = pbLoadSpeciesMetrics selection = 0 species = [ - [_INTL("Name"),LimitStringProperty.new(PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE),_INTL("Name of the Pokémon.")], + [_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_POKEMON_NAME_SIZE), _INTL("Name of the Pokémon.")], [_INTL("InternalName"),ReadOnlyProperty,_INTL("Internal name of the Pokémon.")], [_INTL("Type1"),TypeProperty,_INTL("Pokémon's type. If same as Type2, this Pokémon has a single type.")], [_INTL("Type2"),TypeProperty,_INTL("Pokémon's type. If same as Type1, this Pokémon has a single type.")], diff --git a/Data/Scripts/021_Debug/006_Editor_DataTypes.rb b/Data/Scripts/021_Debug/006_Editor_DataTypes.rb index 6cf4e0f05..d726d3e9c 100644 --- a/Data/Scripts/021_Debug/006_Editor_DataTypes.rb +++ b/Data/Scripts/021_Debug/006_Editor_DataTypes.rb @@ -466,9 +466,9 @@ class EVsProperty for i in 0...6 evtotal += oldsetting[i] if oldsetting[i] end - if evtotal>PokeBattle_Pokemon::EV_LIMIT + if evtotal>Pokemon::EV_LIMIT pbMessage(_INTL("Total EVs ({1}) are greater than allowed ({2}). Please reduce them.", - evtotal,PokeBattle_Pokemon::EV_LIMIT)) + evtotal, Pokemon::EV_LIMIT)) else break end diff --git a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb index c36f32120..02f957bf3 100644 --- a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb +++ b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb @@ -1443,30 +1443,30 @@ def pbCompileTrainers record = [record] if record.is_a?(Integer) record.compact! for i in record - next if i<=PokeBattle_Pokemon::IV_STAT_LIMIT - raise _INTL("Bad IV: {1} (must be 0-{2})\r\n{3}",i,PokeBattle_Pokemon::IV_STAT_LIMIT,FileLineData.linereport) + next if i<=Pokemon::IV_STAT_LIMIT + raise _INTL("Bad IV: {1} (must be 0-{2})\r\n{3}", i, Pokemon::IV_STAT_LIMIT, FileLineData.linereport) end when "EV" record = [record] if record.is_a?(Integer) record.compact! for i in record - next if i<=PokeBattle_Pokemon::EV_STAT_LIMIT - raise _INTL("Bad EV: {1} (must be 0-{2})\r\n{3}",i,PokeBattle_Pokemon::EV_STAT_LIMIT,FileLineData.linereport) + next if i<=Pokemon::EV_STAT_LIMIT + raise _INTL("Bad EV: {1} (must be 0-{2})\r\n{3}", i, Pokemon::EV_STAT_LIMIT, FileLineData.linereport) end evtotal = 0 for i in 0...6 evtotal += (iPokeBattle_Pokemon::EV_LIMIT - raise _INTL("Total EVs are greater than allowed ({1})\r\n{2}",PokeBattle_Pokemon::EV_LIMIT,FileLineData.linereport) + if evtotal>Pokemon::EV_LIMIT + raise _INTL("Total EVs are greater than allowed ({1})\r\n{2}", Pokemon::EV_LIMIT, FileLineData.linereport) end when "Happiness" if record>255 raise _INTL("Bad happiness: {1} (must be 0-255)\r\n{2}",record,FileLineData.linereport) end when "Name" - if record.length>PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE - raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}",record,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,FileLineData.linereport) + if record.length>Pokemon::MAX_POKEMON_NAME_SIZE + raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}", record, Pokemon::MAX_POKEMON_NAME_SIZE, FileLineData.linereport) end end # Record XXX=YYY setting @@ -1546,8 +1546,8 @@ def pbCompileTrainers end record[i] = [record[i]] when TPEV+3 - if record[i]>PokeBattle_Pokemon::EV_STAT_LIMIT - raise _INTL("Bad EV: {1} (must be 0-{2})\r\n{3}",record[i],PokeBattle_Pokemon::EV_STAT_LIMIT,FileLineData.linereport) + if record[i]>Pokemon::EV_STAT_LIMIT + raise _INTL("Bad EV: {1} (must be 0-{2})\r\n{3}", record[i], Pokemon::EV_STAT_LIMIT, FileLineData.linereport) end record[i] = [record[i]] when TPHAPPINESS+3 @@ -1555,8 +1555,8 @@ def pbCompileTrainers raise _INTL("Bad happiness: {1} (must be 0-255)\r\n{2}",record[i],FileLineData.linereport) end when TPNAME+3 - if record[i].length>PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE - raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}",record[i],PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,FileLineData.linereport) + if record[i].length>Pokemon::MAX_POKEMON_NAME_SIZE + raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}", record[i], Pokemon::MAX_POKEMON_NAME_SIZE, FileLineData.linereport) end end end From 2696e15f67e862f96a1640c32236b1172b2b607b Mon Sep 17 00:00:00 2001 From: jonisavo Date: Sun, 20 Sep 2020 20:57:26 +0300 Subject: [PATCH 03/12] Fix Debug Console not opening --- Data/Scripts/001_Technical/006_DebugConsole.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Data/Scripts/001_Technical/006_DebugConsole.rb b/Data/Scripts/001_Technical/006_DebugConsole.rb index 0c20df963..6a608ea38 100644 --- a/Data/Scripts/001_Technical/006_DebugConsole.rb +++ b/Data/Scripts/001_Technical/006_DebugConsole.rb @@ -48,6 +48,7 @@ module Console @apiSetConsoleTitle = Win32API.new("kernel32","SetConsoleTitle","p","s") access = (GENERIC_READ | GENERIC_WRITE) sharemode = (FILE_SHARE_READ | FILE_SHARE_WRITE) + AllocConsole() @bufferHandle = CreateConsoleScreenBuffer(access,sharemode,CONSOLE_TEXTMODE_BUFFER) f = File.open("Game.ini") lines = f.readlines() From 61ad59afa63dfab284f0c7373d54318c10267abd Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Sun, 20 Sep 2020 21:24:05 +0300 Subject: [PATCH 04/12] Create 009_Pokemon_Deprecated.rb --- Data/Scripts/016_Pokemon/001_Pokemon.rb | 20 ------------------- .../016_Pokemon/009_Pokemon_Deprecated.rb | 19 ++++++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 88c76a4c0..73eb0b4b3 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -1120,23 +1120,3 @@ class Pokemon end end end - -#=============================================================================== -# Deprecated classes & methods -#=============================================================================== - -# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias -# and is slated to be removed in vXX. -class PokeBattle_Pokemon; end - -PokeBattle_Pokemon = Pokemon - -# (see Pokemon#initialize) -# @deprecated Use +Pokemon.new+ instead. This method and its aliases are -# slated to be removed in vXX. -def pbNewPkmn(species, level, owner = $Trainer, withMoves = true) - Kernel.echoln("WARN: pbNewPkmn and its aliases are deprecated and slated to be removed in Essentials vXX") - return Pokemon.new(species, level, owner, withMoves) -end -alias pbGenPkmn pbNewPkmn -alias pbGenPoke pbNewPkmn diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb new file mode 100644 index 000000000..fd97aeabe --- /dev/null +++ b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb @@ -0,0 +1,19 @@ +#=============================================================================== +# Deprecated classes & methods for Pokémon +#=============================================================================== + +# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias +# and is slated to be removed in vXX. +class PokeBattle_Pokemon; end + +PokeBattle_Pokemon = Pokemon + +# (see Pokemon#initialize) +# @deprecated Use +Pokemon.new+ instead. This method and its aliases are +# slated to be removed in vXX. +def pbNewPkmn(species, level, owner = $Trainer, withMoves = true) + Kernel.echoln("WARN: pbNewPkmn and its aliases are deprecated and slated to be removed in Essentials vXX") + return Pokemon.new(species, level, owner, withMoves) +end +alias pbGenPkmn pbNewPkmn +alias pbGenPoke pbNewPkmn \ No newline at end of file From 1b7ec64d98dc82763eedda8f2a2de485adf32fae Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Sun, 20 Sep 2020 21:25:39 +0300 Subject: [PATCH 05/12] Rename MAX_POKEMON_NAME_SIZE to MAX_NAME_SIZE in Pokemon --- .../012_Battle/005_Battle scene/008_Scene_Commands.rb | 2 +- Data/Scripts/016_Pokemon/001_Pokemon.rb | 2 +- Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb | 2 +- Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb | 5 +++++ Data/Scripts/017_UI/020_PScreen_EggHatching.rb | 4 ++-- .../004_PSystem_PokemonUtilities.rb | 4 ++-- Data/Scripts/021_Debug/003_Debug_Pokemon.rb | 2 +- Data/Scripts/021_Debug/004_Editor_Screens.rb | 2 +- Data/Scripts/022_Compiler/002_Compiler_PBS.rb | 8 ++++---- 9 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb b/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb index 14ec36425..7b702cfc3 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb @@ -450,7 +450,7 @@ class PokeBattle_Scene # Opens the nicknaming screen for a newly caught Pokémon #============================================================================= def pbNameEntry(helpText,pkmn) - return pbEnterPokemonName(helpText, 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pkmn) + return pbEnterPokemonName(helpText, 0, Pokemon::MAX_NAME_SIZE, "", pkmn) end #============================================================================= diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 73eb0b4b3..337e341a2 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -115,7 +115,7 @@ class Pokemon # Max EVs that a single stat can have EV_STAT_LIMIT = 252 # Maximum length a Pokémon's nickname can be - MAX_POKEMON_NAME_SIZE = 10 + MAX_NAME_SIZE = 10 #============================================================================= # Ownership, obtained information diff --git a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb b/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb index 13bd3433d..fcc8146bb 100644 --- a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb +++ b/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb @@ -54,7 +54,7 @@ def pbPurify(pokemon,scene) speciesname = PBSpecies.getName(pokemon.species) if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?",speciesname)) newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), - 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pokemon) + 0, Pokemon::MAX_NAME_SIZE, "", pokemon) pokemon.name = newname if newname!="" end end diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb index fd97aeabe..2ae486a12 100644 --- a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb @@ -8,6 +8,11 @@ class PokeBattle_Pokemon; end PokeBattle_Pokemon = Pokemon +class Pokemon + # @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in vXX. + MAX_POKEMON_NAME_SIZE = MAX_NAME_SIZE +end + # (see Pokemon#initialize) # @deprecated Use +Pokemon.new+ instead. This method and its aliases are # slated to be removed in vXX. diff --git a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb index ebfea00d9..9cc898fbb 100644 --- a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb +++ b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb @@ -109,7 +109,7 @@ class PokemonEggHatch_Scene if pbConfirmMessage( _INTL("Would you like to nickname the newly hatched {1}?",@pokemon.name)) { update } nickname=pbEnterPokemonName(_INTL("{1}'s nickname?",@pokemon.name), - 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", @pokemon, true) + 0, Pokemon::MAX_NAME_SIZE, "", @pokemon, true) @pokemon.name=nickname if nickname!="" @nicknamed=true end @@ -209,7 +209,7 @@ def pbHatch(pokemon) pbMessage(_INTL("{1} hatched from the Egg!",speciesname)) if pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?",speciesname)) nickname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), - 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pokemon) + 0, Pokemon::MAX_NAME_SIZE, "", pokemon) pokemon.name = nickname if nickname!="" end end diff --git a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb index 377bcb1ab..cfd170a71 100644 --- a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb +++ b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb @@ -9,7 +9,7 @@ def pbNickname(pokemon) speciesname = PBSpecies.getName(pokemon.species) if pbConfirmMessage(_INTL("Would you like to give a nickname to {1}?",speciesname)) helptext = _INTL("{1}'s nickname?",speciesname) - newname = pbEnterPokemonName(helptext, 0, Pokemon::MAX_POKEMON_NAME_SIZE, "", pokemon) + newname = pbEnterPokemonName(helptext, 0, Pokemon::MAX_NAME_SIZE, "", pokemon) pokemon.name = newname if newname!="" end end @@ -146,7 +146,7 @@ def pbAddForeignPokemon(pokemon,level=nil,ownerName=nil,nickname=nil,ownerGender pokemon.otgender = ownerGender end # Set nickname - pokemon.name = nickname[0, Pokemon::MAX_POKEMON_NAME_SIZE] if nickname && nickname!="" + pokemon.name = nickname[0, Pokemon::MAX_NAME_SIZE] if nickname && nickname!="" # Recalculate stats pokemon.calcStats if ownerName diff --git a/Data/Scripts/021_Debug/003_Debug_Pokemon.rb b/Data/Scripts/021_Debug/003_Debug_Pokemon.rb index 52579bbe7..2ec78f7e0 100644 --- a/Data/Scripts/021_Debug/003_Debug_Pokemon.rb +++ b/Data/Scripts/021_Debug/003_Debug_Pokemon.rb @@ -601,7 +601,7 @@ module PokemonDebugMixin when 0 # Rename oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : "" newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), - 0, Pokemon::MAX_POKEMON_NAME_SIZE, oldname, pkmn) + 0, Pokemon::MAX_NAME_SIZE, oldname, pkmn) if newname && newname!="" pkmn.name = newname pbRefreshSingle(pkmnid) diff --git a/Data/Scripts/021_Debug/004_Editor_Screens.rb b/Data/Scripts/021_Debug/004_Editor_Screens.rb index 23ef33eb8..5a87d1665 100644 --- a/Data/Scripts/021_Debug/004_Editor_Screens.rb +++ b/Data/Scripts/021_Debug/004_Editor_Screens.rb @@ -741,7 +741,7 @@ def pbPokemonEditor metrics = pbLoadSpeciesMetrics selection = 0 species = [ - [_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_POKEMON_NAME_SIZE), _INTL("Name of the Pokémon.")], + [_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")], [_INTL("InternalName"),ReadOnlyProperty,_INTL("Internal name of the Pokémon.")], [_INTL("Type1"),TypeProperty,_INTL("Pokémon's type. If same as Type2, this Pokémon has a single type.")], [_INTL("Type2"),TypeProperty,_INTL("Pokémon's type. If same as Type1, this Pokémon has a single type.")], diff --git a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb index 02f957bf3..100c20cfd 100644 --- a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb +++ b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb @@ -1465,8 +1465,8 @@ def pbCompileTrainers raise _INTL("Bad happiness: {1} (must be 0-255)\r\n{2}",record,FileLineData.linereport) end when "Name" - if record.length>Pokemon::MAX_POKEMON_NAME_SIZE - raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}", record, Pokemon::MAX_POKEMON_NAME_SIZE, FileLineData.linereport) + if record.length>Pokemon::MAX_NAME_SIZE + raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}", record, Pokemon::MAX_NAME_SIZE, FileLineData.linereport) end end # Record XXX=YYY setting @@ -1555,8 +1555,8 @@ def pbCompileTrainers raise _INTL("Bad happiness: {1} (must be 0-255)\r\n{2}",record[i],FileLineData.linereport) end when TPNAME+3 - if record[i].length>Pokemon::MAX_POKEMON_NAME_SIZE - raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}", record[i], Pokemon::MAX_POKEMON_NAME_SIZE, FileLineData.linereport) + if record[i].length>Pokemon::MAX_NAME_SIZE + raise _INTL("Bad nickname: {1} (must be 1-{2} characters)\r\n{3}", record[i], Pokemon::MAX_NAME_SIZE, FileLineData.linereport) end end end From 7257c7479f5a6068ae826812963f5deb7a7be527 Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Sun, 20 Sep 2020 21:34:06 +0300 Subject: [PATCH 06/12] Replace all usage of pbNewPkmn with Pokemon.new --- Data/Scripts/013_Overworld/007_PField_Encounters.rb | 2 +- Data/Scripts/013_Overworld/013_PField_DayCare.rb | 2 +- .../Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb | 2 +- Data/Scripts/016_Pokemon/001_Pokemon.rb | 2 +- Data/Scripts/017_UI/022_PScreen_Trading.rb | 2 +- Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb | 4 ++-- .../019_Other battles/002_PBattle_BugContest.rb | 2 +- .../019_Other battles/003_PBattle_OrgBattle.rb | 2 +- .../004_PSystem_PokemonUtilities.rb | 12 ++++++------ Data/Scripts/021_Debug/001_Debug_Menu.rb | 4 ++-- Data/Scripts/021_Debug/002_Debug_Actions.rb | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Data/Scripts/013_Overworld/007_PField_Encounters.rb b/Data/Scripts/013_Overworld/007_PField_Encounters.rb index 1533f62c4..cca9346b6 100644 --- a/Data/Scripts/013_Overworld/007_PField_Encounters.rb +++ b/Data/Scripts/013_Overworld/007_PField_Encounters.rb @@ -404,7 +404,7 @@ end #=============================================================================== # Returns a Pokémon generated by a wild encounter, given its species and level. def pbGenerateWildPokemon(species,level,isRoamer=false) - genwildpoke = pbNewPkmn(species,level) + genwildpoke = Pokemon.new(species,level) # Give the wild Pokémon a held item items = genwildpoke.wildHoldItems firstPkmn = $Trainer.firstPokemon diff --git a/Data/Scripts/013_Overworld/013_PField_DayCare.rb b/Data/Scripts/013_Overworld/013_PField_DayCare.rb index cbf0ef25d..25bd5b0e1 100644 --- a/Data/Scripts/013_Overworld/013_PField_DayCare.rb +++ b/Data/Scripts/013_Overworld/013_PField_DayCare.rb @@ -205,7 +205,7 @@ def pbDayCareGenerateEgg getConst(PBSpecies,:ILLUMISE)][rand(2)] end # Generate egg - egg = pbNewPkmn(babyspecies,EGG_LEVEL) + egg = Pokemon.new(babyspecies,EGG_LEVEL) # Randomise personal ID pid = rand(65536) pid |= (rand(65536)<<16) diff --git a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb index 93a7a4196..e56b7642a 100644 --- a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb +++ b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb @@ -76,7 +76,7 @@ def pbLoadTrainer(trainerid,trainername,partyid=0) for poke in trainer[3] species = pbGetSpeciesFromFSpecies(poke[TPSPECIES])[0] level = poke[TPLEVEL] - pokemon = pbNewPkmn(species,level,opponent,false) + pokemon = Pokemon.new(species,level,opponent,false) if poke[TPFORM] pokemon.forcedForm = poke[TPFORM] if MultipleForms.hasFunction?(pokemon.species,"getForm") pokemon.formSimple = poke[TPFORM] diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 337e341a2..7dd0b1b12 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -115,7 +115,7 @@ class Pokemon # Max EVs that a single stat can have EV_STAT_LIMIT = 252 # Maximum length a Pokémon's nickname can be - MAX_NAME_SIZE = 10 + MAX_NAME_SIZE = 10 #============================================================================= # Ownership, obtained information diff --git a/Data/Scripts/017_UI/022_PScreen_Trading.rb b/Data/Scripts/017_UI/022_PScreen_Trading.rb index 059d269ea..0c9a1aec4 100644 --- a/Data/Scripts/017_UI/022_PScreen_Trading.rb +++ b/Data/Scripts/017_UI/022_PScreen_Trading.rb @@ -206,7 +206,7 @@ def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) raise _INTL("Species does not exist ({1}).",newpoke) if !hasConst?(PBSpecies,newpoke) newpoke = getID(PBSpecies,newpoke) end - yourPokemon = pbNewPkmn(newpoke,myPokemon.level,opponent) + yourPokemon = Pokemon.new(newpoke,myPokemon.level,opponent) end yourPokemon.name = nickname yourPokemon.obtainMode = 2 # traded diff --git a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb index a06830d2f..34778bd6c 100644 --- a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb +++ b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb @@ -212,14 +212,14 @@ class PurifyChamber # German: der Kryptorbis def debugAddShadow(set,species) species=getID(PBSpecies,species) - pkmn=pbNewPkmn(species,1) + pkmn=Pokemon.new(species,1) pkmn.makeShadow setShadow(set,pkmn) end def debugAddNormal(set,species) species=getID(PBSpecies,species) - pkmn=pbNewPkmn(species,1) + pkmn=Pokemon.new(species,1) insertAfter(set,setCount(set),pkmn) end diff --git a/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb b/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb index a91efd05e..daf7b3601 100644 --- a/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb +++ b/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb @@ -114,7 +114,7 @@ class BugContestState if !enc raise _INTL("No encounters for map {1}, so can't judge contest",@contestMap) end - pokemon=pbNewPkmn(enc[0],enc[1]) + pokemon=Pokemon.new(enc[0],enc[1]) pokemon.hp=1+rand(pokemon.totalhp-1) score=pbBugContestScore(pokemon) judgearray.push([cont,pokemon.species,score]) diff --git a/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb b/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb index e767e51e5..d532e1c0c 100644 --- a/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb +++ b/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb @@ -159,7 +159,7 @@ class PBPokemon end def createPokemon(level,iv,trainer) - pokemon=pbNewPkmn(@species,level,trainer,false) + pokemon=Pokemon.new(@species,level,trainer,false) pokemon.setItem(@item) pokemon.personalID=rand(65536) pokemon.personalID|=rand(65536)<<8 diff --git a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb index cfd170a71..d78110ce5 100644 --- a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb +++ b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb @@ -74,7 +74,7 @@ def pbAddPokemon(pokemon,level=nil,seeform=true) end pokemon = getID(PBSpecies,pokemon) if pokemon.is_a?(Integer) && level.is_a?(Integer) - pokemon = pbNewPkmn(pokemon,level) + pokemon = Pokemon.new(pokemon,level) end speciesname = PBSpecies.getName(pokemon.species) pbMessage(_INTL("\\me[Pkmn get]{1} obtained {2}!\1",$Trainer.name,speciesname)) @@ -87,7 +87,7 @@ def pbAddPokemonSilent(pokemon,level=nil,seeform=true) return false if !pokemon || pbBoxesFull? pokemon = getID(PBSpecies,pokemon) if pokemon.is_a?(Integer) && level.is_a?(Integer) - pokemon = pbNewPkmn(pokemon,level) + pokemon = Pokemon.new(pokemon,level) end $Trainer.seen[pokemon.species] = true $Trainer.owned[pokemon.species] = true @@ -110,7 +110,7 @@ def pbAddToParty(pokemon,level=nil,seeform=true) return false if !pokemon || $Trainer.party.length>=6 pokemon = getID(PBSpecies,pokemon) if pokemon.is_a?(Integer) && level.is_a?(Integer) - pokemon = pbNewPkmn(pokemon,level) + pokemon = Pokemon.new(pokemon,level) end speciesname = PBSpecies.getName(pokemon.species) pbMessage(_INTL("\\me[Pkmn get]{1} obtained {2}!\1",$Trainer.name,speciesname)) @@ -123,7 +123,7 @@ def pbAddToPartySilent(pokemon,level=nil,seeform=true) return false if !pokemon || $Trainer.party.length>=6 pokemon = getID(PBSpecies,pokemon) if pokemon.is_a?(Integer) && level.is_a?(Integer) - pokemon = pbNewPkmn(pokemon,level) + pokemon = Pokemon.new(pokemon,level) end $Trainer.seen[pokemon.species] = true $Trainer.owned[pokemon.species] = true @@ -137,7 +137,7 @@ def pbAddForeignPokemon(pokemon,level=nil,ownerName=nil,nickname=nil,ownerGender return false if !pokemon || $Trainer.party.length>=6 pokemon = getID(PBSpecies,pokemon) if pokemon.is_a?(Integer) && level.is_a?(Integer) - pokemon = pbNewPkmn(pokemon,level) + pokemon = Pokemon.new(pokemon,level) end # Set original trainer to a foreign one (if ID isn't already foreign) if pokemon.trainerID==$Trainer.id @@ -165,7 +165,7 @@ def pbGenerateEgg(pokemon,text="") return false if !pokemon || $Trainer.party.length>=6 pokemon = getID(PBSpecies,pokemon) if pokemon.is_a?(Integer) - pokemon = pbNewPkmn(pokemon,EGG_LEVEL) + pokemon = Pokemon.new(pokemon,EGG_LEVEL) end # Get egg steps eggSteps = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesStepsToHatch) diff --git a/Data/Scripts/021_Debug/001_Debug_Menu.rb b/Data/Scripts/021_Debug/001_Debug_Menu.rb index ba7f3b3a4..d75f1d37d 100644 --- a/Data/Scripts/021_Debug/001_Debug_Menu.rb +++ b/Data/Scripts/021_Debug/001_Debug_Menu.rb @@ -348,7 +348,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil) params.setCancelValue(0) level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.",PBSpecies.getName(species)),params) if level>0 - pkmn.push(pbNewPkmn(species,level)) + pkmn.push(Pokemon.new(species,level)) end end else # Edit a Pokémon @@ -563,7 +563,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil) end cname = getConstantName(PBSpecies,i) rescue nil next if !cname - pkmn = pbNewPkmn(i,50) + pkmn = Pokemon.new(i,50) $PokemonStorage[(i-1)/$PokemonStorage.maxPokemon(0), (i-1)%$PokemonStorage.maxPokemon(0)] = pkmn # Record all forms of this Pokémon as seen and owned diff --git a/Data/Scripts/021_Debug/002_Debug_Actions.rb b/Data/Scripts/021_Debug/002_Debug_Actions.rb index d42b9bb53..158b30245 100644 --- a/Data/Scripts/021_Debug/002_Debug_Actions.rb +++ b/Data/Scripts/021_Debug/002_Debug_Actions.rb @@ -527,7 +527,7 @@ def pbCreatePokemon for i in 0...party.length species = party[i] # Generate Pokémon with species and level 20 - $Trainer.party[i] = pbNewPkmn(species,20) + $Trainer.party[i] = Pokemon.new(species,20) $Trainer.seen[species] = true # Set this species to seen and owned $Trainer.owned[species] = true pbSeenForm($Trainer.party[i]) From d62c340b285438f5ac59aceda7f494fb07c78a4b Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Mon, 21 Sep 2020 08:20:11 +0300 Subject: [PATCH 07/12] Better description for Pokemon_Deprecated.rb --- Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb index 2ae486a12..08904006a 100644 --- a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb @@ -1,5 +1,6 @@ #=============================================================================== -# Deprecated classes & methods for Pokémon +# Deprecated classes, methods and constants for Pokémon. +# These will be removed in a future Essentials version. #=============================================================================== # @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias From a5b04d6eb32e494f74f9b62817dc64eabe9cffd5 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Mon, 21 Sep 2020 08:30:28 +0100 Subject: [PATCH 08/12] Fixed typo in Judgment's code --- Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb b/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb index 050a889de..b362b482d 100644 --- a/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb +++ b/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb @@ -777,7 +777,7 @@ class PokeBattle_Move_09F < PokeBattle_Move if user.itemActive? @itemTypes.each do |item, itemType| next if !isConst?(user.item,PBItems,item) - t = hasConst?(PBTypes,itemType) + t = getConst(PBTypes,itemType) ret = t || ret break end From 7749dec2d4135d691402badd819f6dd7112e5330 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Mon, 21 Sep 2020 19:23:59 +0100 Subject: [PATCH 09/12] Fixed default weather not returning after a primal weather ends --- Data/Scripts/012_Battle/003_Battle/002_PokeBattle_Battle.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/012_Battle/003_Battle/002_PokeBattle_Battle.rb b/Data/Scripts/012_Battle/003_Battle/002_PokeBattle_Battle.rb index 8beb8a7e4..73d952058 100644 --- a/Data/Scripts/012_Battle/003_Battle/002_PokeBattle_Battle.rb +++ b/Data/Scripts/012_Battle/003_Battle/002_PokeBattle_Battle.rb @@ -692,9 +692,11 @@ class PokeBattle_Battle pbDisplay("The mysterious air current has dissipated!") end end - # Check for form changes caused by the weather changing if @field.weather!=oldWeather + # Check for form changes caused by the weather changing eachBattler { |b| b.pbCheckFormOnWeatherChange } + # Start up the default weather + pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather!=PBWeather::None end end From 194654dbd7a7c5922796a9d99748db6b40c18df8 Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Wed, 23 Sep 2020 20:24:31 +0300 Subject: [PATCH 10/12] Add 009_Deprecation.rb --- Data/Scripts/001_Technical/009_Deprecation.rb | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Data/Scripts/001_Technical/009_Deprecation.rb diff --git a/Data/Scripts/001_Technical/009_Deprecation.rb b/Data/Scripts/001_Technical/009_Deprecation.rb new file mode 100644 index 000000000..0168bb52e --- /dev/null +++ b/Data/Scripts/001_Technical/009_Deprecation.rb @@ -0,0 +1,52 @@ +# The Deprecation module is used to warn game & plugin creators of deprecated +# methods. +module Deprecation + module_function + + # Sends a warning of a deprecated method into the debug console. + # @param method_name [String] name of the deprecated method + # @param removal_version [String] name of the version the method is removed in (optional) + # @param alternative [String] preferred alternative method (optional) + def warn_method(method_name, removal_version = nil, alternative = nil) + text = _INTL('WARN: usage of deprecated method "{1}" or its alias.', method_name) + unless removal_version.nil? + text += _INTL("\nThe method is slated to be"\ + " removed in Essentials {1}.", removal_version) + end + unless alternative.nil? + text += _INTL("\nUse \"{1}\" instead.", alternative) + end + echoln text + end +end + +# The Module class is extended to allow easy deprecation of instance and class methods. +class Module + private + + # Creates a deprecated alias for an instance method. + # Using it sends a warning to the debug console. + # @param alias_name [Symbol] the name of the new alias + # @param aliased_method_name [Symbol] the name of the aliased method + # @param removal_version [String] name of the version the alias is removed in (optional) + def deprecated_instance_method_alias(alias_name, aliased_method_name, removal_version = nil) + define_method(alias_name) do |*args| + alias_full_name = format('%s#%s', self.class.name, alias_name.to_s) + aliased_method_full_name = format('%s#%s', self.class.name, aliased_method_name.to_s) + Deprecation.warn_method(alias_full_name, removal_version, aliased_method_full_name) + method(aliased_method_name).call(*args) + end + end + + # Creates a deprecated alias for a class method. + # Using it sends a warning to the debug console. + # @param (see #deprecated_instance_method_alias) + def deprecated_class_method_alias(alias_name, aliased_method_name, removal_version = nil) + self.class.send(:define_method, alias_name) do |*args| + alias_full_name = format('%s::%s', self.name, alias_name.to_s) + aliased_method_full_name = format('%s::%s', self.name, aliased_method_name.to_s) + Deprecation.warn_method(alias_full_name, removal_version, aliased_method_full_name) + method(aliased_method_name).call(*args) + end + end +end From 41a304f5686bff73982cdfcbf578388f7cc29c38 Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Wed, 23 Sep 2020 20:26:29 +0300 Subject: [PATCH 11/12] Initial testing of deprecation --- Data/Scripts/016_Pokemon/001_Pokemon.rb | 7 +++---- Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb | 7 +++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 7dd0b1b12..66fc31e8d 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -96,7 +96,7 @@ class Pokemon # Otherwise returns 0. # @return [Integer] the map ID where egg was hatched (0 by default) attr_accessor :hatchedMap - # @param value [Integer] new language + # @param value [Integer] new language attr_writer :language # @return [String] the name of the original trainer attr_accessor :ot @@ -122,7 +122,7 @@ class Pokemon #============================================================================= # @return [Integer] the public portion of the original trainer's ID - def publicID + def public_id return @trainerID & 0xFFFF end @@ -131,7 +131,6 @@ class Pokemon def foreign?(trainer) return @trainerID != trainer.id || @ot != trainer.name end - alias isForeign? foreign? # @return [0, 1, 2] the gender of this Pokémon original trainer (0 = male, 1 = female, 2 = unknown) def otgender @@ -139,7 +138,7 @@ class Pokemon end # @return [Integer] this Pokémon's level when it was obtained - def obtainLevel + def obtain_level return @obtainLevel || 0 end diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb index 08904006a..12dfe2b97 100644 --- a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb @@ -12,14 +12,17 @@ PokeBattle_Pokemon = Pokemon class Pokemon # @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in vXX. MAX_POKEMON_NAME_SIZE = MAX_NAME_SIZE + + deprecated_instance_method_alias :publicID, :public_id, 'vXX' + deprecated_instance_method_alias :isForeign?, :foreign?, 'vXX' end # (see Pokemon#initialize) # @deprecated Use +Pokemon.new+ instead. This method and its aliases are # slated to be removed in vXX. def pbNewPkmn(species, level, owner = $Trainer, withMoves = true) - Kernel.echoln("WARN: pbNewPkmn and its aliases are deprecated and slated to be removed in Essentials vXX") + Deprecation.warn_method('pbNewPkmn', 'vXX', 'Pokemon.new') return Pokemon.new(species, level, owner, withMoves) end alias pbGenPkmn pbNewPkmn -alias pbGenPoke pbNewPkmn \ No newline at end of file +alias pbGenPoke pbNewPkmn From ca761640f802ce7e8cafa31f15b67d9f89785f14 Mon Sep 17 00:00:00 2001 From: Joni Savolainen Date: Thu, 24 Sep 2020 08:34:23 +0300 Subject: [PATCH 12/12] Revert rename of Pokemon#publicID & #obtainLevel These changes should be done in their own branch. --- Data/Scripts/016_Pokemon/001_Pokemon.rb | 13 +++++++------ Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Data/Scripts/016_Pokemon/001_Pokemon.rb b/Data/Scripts/016_Pokemon/001_Pokemon.rb index 66fc31e8d..0feb2cefe 100644 --- a/Data/Scripts/016_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_Pokemon.rb @@ -109,20 +109,20 @@ class Pokemon attr_writer :cool,:beauty,:cute,:smart,:tough,:sheen # Max total IVs - IV_STAT_LIMIT = 31 + IV_STAT_LIMIT = 31 # Max total EVs - EV_LIMIT = 510 + EV_LIMIT = 510 # Max EVs that a single stat can have - EV_STAT_LIMIT = 252 + EV_STAT_LIMIT = 252 # Maximum length a Pokémon's nickname can be - MAX_NAME_SIZE = 10 + MAX_NAME_SIZE = 10 #============================================================================= # Ownership, obtained information #============================================================================= # @return [Integer] the public portion of the original trainer's ID - def public_id + def publicID return @trainerID & 0xFFFF end @@ -131,6 +131,7 @@ class Pokemon def foreign?(trainer) return @trainerID != trainer.id || @ot != trainer.name end + alias isForeign? foreign? # @return [0, 1, 2] the gender of this Pokémon original trainer (0 = male, 1 = female, 2 = unknown) def otgender @@ -138,7 +139,7 @@ class Pokemon end # @return [Integer] this Pokémon's level when it was obtained - def obtain_level + def obtainLevel return @obtainLevel || 0 end diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb index 12dfe2b97..8f89c4b55 100644 --- a/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb +++ b/Data/Scripts/016_Pokemon/009_Pokemon_Deprecated.rb @@ -12,9 +12,6 @@ PokeBattle_Pokemon = Pokemon class Pokemon # @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in vXX. MAX_POKEMON_NAME_SIZE = MAX_NAME_SIZE - - deprecated_instance_method_alias :publicID, :public_id, 'vXX' - deprecated_instance_method_alias :isForeign?, :foreign?, 'vXX' end # (see Pokemon#initialize)