Created and implemented GameData::Type

This commit is contained in:
Maruno17
2020-12-12 21:26:46 +00:00
parent c8790bafc9
commit bc13517cb7
50 changed files with 698 additions and 784 deletions

View File

@@ -303,35 +303,31 @@ class PokeBattle_Battler
ret = [@type1]
ret.push(@type2) if @type2!=@type1
# Burn Up erases the Fire-type.
if @effects[PBEffects::BurnUp]
ret.reject! { |type| isConst?(type,PBTypes,:FIRE) }
end
ret.delete(:FIRE) if @effects[PBEffects::BurnUp]
# Roost erases the Flying-type. If there are no types left, adds the Normal-
# type.
if @effects[PBEffects::Roost]
ret.reject! { |type| isConst?(type,PBTypes,:FLYING) }
ret.push(getConst(PBTypes,:NORMAL) || 0) if ret.length==0
ret.delete(:FLYING)
ret.push(:NORMAL) if ret.length == 0
end
# Add the third type specially.
if withType3 && @effects[PBEffects::Type3]>=0
if withType3 && @effects[PBEffects::Type3]
ret.push(@effects[PBEffects::Type3]) if !ret.include?(@effects[PBEffects::Type3])
end
return ret
end
def pbHasType?(type)
type = getConst(PBTypes,type) if type.is_a?(Symbol) || type.is_a?(String)
return false if !type || type<0
return false if !type
activeTypes = pbTypes(true)
return activeTypes.include?(type)
return activeTypes.include?(GameData::Type.get(type).id)
end
def pbHasOtherType?(type)
type = getConst(PBTypes,type) if type.is_a?(Symbol) || type.is_a?(String)
return false if !type || type<0
return false if !type
activeTypes = pbTypes(true)
activeTypes.reject! { |t| t==type }
return activeTypes.length>0
activeTypes.delete(GameData::Type.get(type).id)
return activeTypes.length > 0
end
# NOTE: Do not create any held item which affects whether a Pokémon's ability
@@ -444,8 +440,8 @@ class PokeBattle_Battler
end
def pbHasMoveType?(check_type)
check_type = getConst(PBTypes, check_type)
return false if !check_type || check_type < 0
return false if !check_type
check_type = GameData::Type.get(check_type).id
eachMove { |m| return true if m.type == check_type }
return false
end

View File

@@ -20,7 +20,7 @@ class PokeBattle_Battler
@form = 0
@level = 0
@hp = @totalhp = 0
@type1 = @type2 = 0
@type1 = @type2 = nil
@ability_id = nil
@item_id = nil
@gender = 0
@@ -148,7 +148,7 @@ class PokeBattle_Battler
@tookDamage = false
@tookPhysicalHit = false
@lastMoveUsed = nil
@lastMoveUsedType = -1
@lastMoveUsedType = nil
@lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1
@lastRoundMoved = -1
@@ -270,7 +270,7 @@ class PokeBattle_Battler
end
@effects[PBEffects::Truant] = false
@effects[PBEffects::TwoTurnAttack] = nil
@effects[PBEffects::Type3] = -1
@effects[PBEffects::Type3] = nil
@effects[PBEffects::Unburden] = false
@effects[PBEffects::Uproar] = 0
@effects[PBEffects::WaterSport] = false

View File

@@ -111,17 +111,17 @@ class PokeBattle_Battler
def pbChangeTypes(newType)
if newType.is_a?(PokeBattle_Battler)
newTypes = newType.pbTypes
newTypes.push(getConst(PBTypes,:NORMAL) || 0) if newTypes.length==0
newTypes.push(:NORMAL) if newTypes.length == 0
newType3 = newType.effects[PBEffects::Type3]
newType3 = -1 if newTypes.include?(newType3)
newType3 = nil if newTypes.include?(newType3)
@type1 = newTypes[0]
@type2 = (newTypes.length==1) ? newTypes[0] : newTypes[1]
@type2 = (newTypes.length == 1) ? newTypes[0] : newTypes[1]
@effects[PBEffects::Type3] = newType3
else
newType = getConst(PBTypes,newType) if newType.is_a?(Symbol) || newType.is_a?(String)
newType = GameData::Item.get(newType).id
@type1 = newType
@type2 = newType
@effects[PBEffects::Type3] = -1
@effects[PBEffects::Type3] = nil
end
@effects[PBEffects::BurnUp] = false
@effects[PBEffects::Roost] = false

View File

@@ -125,7 +125,7 @@ class PokeBattle_Battler
@damageState.reset
@damageState.initialHP = @hp
confusionMove = PokeBattle_Confusion.new(@battle,nil)
confusionMove.calcType = confusionMove.pbCalcType(self) # -1
confusionMove.calcType = confusionMove.pbCalcType(self) # nil
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType,self,self) # 8
confusionMove.pbCheckDamageAbsorption(self,self)
confusionMove.pbCalcDamage(self,self)
@@ -189,7 +189,7 @@ class PokeBattle_Battler
@lastMoveFailed = false
if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
@lastMoveUsed = nil
@lastMoveUsedType = -1
@lastMoveUsedType = nil
if !specialUsage
@lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1
@@ -207,7 +207,7 @@ class PokeBattle_Battler
@battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name))
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
@lastMoveUsed = nil
@lastMoveUsedType = -1
@lastMoveUsedType = nil
@lastRegularMoveUsed = nil
@lastRegularMoveTarget = -1
@lastMoveFailed = true
@@ -319,7 +319,7 @@ class PokeBattle_Battler
@battle.pbDisplay(_INTL("{1} melted the ice!",user.pbThis))
end
# Powder
if user.effects[PBEffects::Powder] && isConst?(move.calcType,PBTypes,:FIRE)
if user.effects[PBEffects::Powder] && move.calcType == :FIRE
@battle.pbCommonAnimation("Powder",user)
@battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!"))
user.lastMoveFailed = true
@@ -342,7 +342,7 @@ class PokeBattle_Battler
if move.damagingMove?
case @battle.pbWeather
when PBWeather::HeavyRain
if isConst?(move.calcType,PBTypes,:FIRE)
if move.calcType == :FIRE
@battle.pbDisplay(_INTL("The Fire-type attack fizzled out in the heavy rain!"))
user.lastMoveFailed = true
pbCancelMoves
@@ -350,7 +350,7 @@ class PokeBattle_Battler
return
end
when PBWeather::HarshSun
if isConst?(move.calcType,PBTypes,:WATER)
if move.calcType == :WATER
@battle.pbDisplay(_INTL("The Water-type attack evaporated in the harsh sunlight!"))
user.lastMoveFailed = true
pbCancelMoves
@@ -364,7 +364,7 @@ class PokeBattle_Battler
if user.pbHasOtherType?(move.calcType) && !PBTypes.isPseudoType?(move.calcType)
@battle.pbShowAbilitySplash(user)
user.pbChangeTypes(move.calcType)
typeName = PBTypes.getName(move.calcType)
typeName = GameData::Type.get(move.calcType).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName))
@battle.pbHideAbilitySplash(user)
# NOTE: The GF games say that if Curse is used by a non-Ghost-type

View File

@@ -138,7 +138,7 @@ class PokeBattle_Battler
end
def pbChangeTargetByAbility(drawingAbility,drawnType,move,user,targets,priority,nearOnly)
return targets if !isConst?(move.calcType,PBTypes,drawnType)
return targets if move.calcType != drawnType
return targets if targets[0].hasActiveAbility?(drawingAbility)
priority.each do |b|
next if b.index==user.index || b.index==targets[0].index

View File

@@ -402,7 +402,7 @@ class PokeBattle_Battler
# Immunity because of ability (intentionally before type immunity check)
return false if move.pbImmunityByAbility(user,target)
# Type immunity
if move.pbDamagingMove? && PBTypes.ineffective?(typeMod)
if move.pbDamagingMove? && PBTypeEffectiveness.ineffective?(typeMod)
PBDebug.log("[Target immune] #{target.pbThis}'s type immunity")
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
return false
@@ -415,7 +415,7 @@ class PokeBattle_Battler
return false
end
# Airborne-based immunity to Ground moves
if move.damagingMove? && isConst?(move.calcType,PBTypes,:GROUND) &&
if move.damagingMove? && move.calcType == :GROUND &&
target.airborne? && !move.hitsFlyingTargets?
if target.hasActiveAbility?(:LEVITATE) && !@battle.moldBreaker
@battle.pbShowAbilitySplash(target)

View File

@@ -72,8 +72,7 @@ class PokeBattle_Battler
next if b.status!=PBStatuses::FROZEN
# NOTE: Non-Fire-type moves that thaw the user will also thaw the
# target (in Gen 6+).
if isConst?(move.calcType,PBTypes,:FIRE) ||
(NEWEST_BATTLE_MECHANICS && move.thawsUser?)
if move.calcType == :FIRE || (NEWEST_BATTLE_MECHANICS && move.thawsUser?)
b.pbCureStatus
end
end

View File

@@ -39,7 +39,7 @@ class PokeBattle_Move
@target = move.target
@priority = move.priority
@flags = move.flags
@calcType = -1
@calcType = nil
@powerBoost = false # For Aerilate, Pixilate, Refrigerate, Galvanize
@snatched = false
end
@@ -72,8 +72,9 @@ class PokeBattle_Move
# AI), so using @calcType here is acceptable.
def physicalMove?(thisType=nil)
return (@category==0) if MOVE_CATEGORY_PER_MOVE
thisType ||= @calcType if @calcType>=0
thisType = @type if !thisType
thisType ||= @calcType
thisType ||= @type
return true if !thisType
return !PBTypes.isSpecialType?(thisType)
end
@@ -81,8 +82,9 @@ class PokeBattle_Move
# AI), so using @calcType here is acceptable.
def specialMove?(thisType=nil)
return (@category==1) if MOVE_CATEGORY_PER_MOVE
thisType ||= @calcType if @calcType>=0
thisType = @type if !thisType
thisType ||= @calcType
thisType ||= @type
return false if !thisType
return PBTypes.isSpecialType?(thisType)
end

View File

@@ -234,8 +234,8 @@ class PokeBattle_Move
oldHP = b.hp+b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
effectiveness = 0
if PBTypes.resistant?(b.damageState.typeMod); effectiveness = 1
elsif PBTypes.superEffective?(b.damageState.typeMod); effectiveness = 2
if PBTypeEffectiveness.resistant?(b.damageState.typeMod); effectiveness = 1
elsif PBTypeEffectiveness.superEffective?(b.damageState.typeMod); effectiveness = 2
end
animArray.push([b,oldHP,effectiveness])
end
@@ -251,13 +251,13 @@ class PokeBattle_Move
#=============================================================================
def pbEffectivenessMessage(user,target,numTargets=1)
return if target.damageState.disguise
if PBTypes.superEffective?(target.damageState.typeMod)
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
if numTargets>1
@battle.pbDisplay(_INTL("It's super effective on {1}!",target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It's super effective!"))
end
elsif PBTypes.notVeryEffective?(target.damageState.typeMod)
elsif PBTypeEffectiveness.notVeryEffective?(target.damageState.typeMod)
if numTargets>1
@battle.pbDisplay(_INTL("It's not very effective on {1}...",target.pbThis(true)))
else
@@ -326,7 +326,7 @@ class PokeBattle_Move
# regardless of its calculated type. Hence the following two lines of
# code.
moveType = nil
moveType = getID(PBTypes,:NORMAL) if @function=="090" # Hidden Power
moveType = :NORMAL if @function=="090" # Hidden Power
if physicalMove?(moveType)
target.effects[PBEffects::Counter] = damage
target.effects[PBEffects::CounterTarget] = user.index

View File

@@ -4,8 +4,7 @@ class PokeBattle_Move
#=============================================================================
def pbBaseType(user)
ret = @type
return ret if !ret || ret<0
if user.abilityActive?
if ret && user.abilityActive?
ret = BattleHandlers.triggerMoveBaseTypeModifierAbility(user.ability,user,self,ret)
end
return ret
@@ -14,14 +13,13 @@ class PokeBattle_Move
def pbCalcType(user)
@powerBoost = false
ret = pbBaseType(user)
return ret if !ret || ret<0
if hasConst?(PBTypes,:ELECTRIC)
if @battle.field.effects[PBEffects::IonDeluge] && isConst?(ret,PBTypes,:NORMAL)
ret = getConst(PBTypes,:ELECTRIC)
if ret && GameData::Type.exists?(:ELECTRIC)
if @battle.field.effects[PBEffects::IonDeluge] && ret == :NORMAL
ret = :ELECTRIC
@powerBoost = false
end
if user.effects[PBEffects::Electrify]
ret = getConst(PBTypes,:ELECTRIC)
ret = :ELECTRIC
@powerBoost = false
end
end
@@ -39,30 +37,29 @@ class PokeBattle_Move
end
# Foresight
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:GHOST) &&
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
PBTypes.ineffective?(moveType,defType)
end
# Miracle Eye
if target.effects[PBEffects::MiracleEye]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:DARK) &&
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
PBTypes.ineffective?(moveType,defType)
end
# Delta Stream's weather
if @battle.pbWeather==PBWeather::StrongWinds
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:FLYING) &&
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
PBTypes.superEffective?(moveType,defType)
end
# Grounded Flying-type Pokémon become susceptible to Ground moves
if !target.airborne?
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:FLYING) &&
isConst?(moveType,PBTypes,:GROUND)
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
end
return ret
end
def pbCalcTypeMod(moveType,user,target)
return PBTypeEffectiveness::NORMAL_EFFECTIVE if moveType<0
return PBTypeEffectiveness::NORMAL_EFFECTIVE if isConst?(moveType,PBTypes,:GROUND) &&
return PBTypeEffectiveness::NORMAL_EFFECTIVE if !moveType
return PBTypeEffectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL)
# Determine types
tTypes = target.pbTypes(true)
@@ -190,7 +187,7 @@ class PokeBattle_Move
return true if user.effects[PBEffects::LaserFocus]>0
c += 1 if highCriticalRate?
c += user.effects[PBEffects::FocusEnergy]
c += 1 if user.inHyperMode? && isConst?(@type,PBTypes,:SHADOW)
c += 1 if user.inHyperMode? && @type == :SHADOW
c = ratios.length-1 if c>=ratios.length
# Calculation
return @battle.pbRandom(ratios[c])==0
@@ -226,7 +223,7 @@ class PokeBattle_Move
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
# Get the move's type
type = @calcType # -1 is treated as physical
type = @calcType # nil is treated as physical
# Calculate whether this hit deals critical damage
target.damageState.critical = pbIsCritical?(user,target)
# Calcuate base power of move
@@ -257,8 +254,8 @@ class PokeBattle_Move
def pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
# Global abilities
if (@battle.pbCheckGlobalAbility(:DARKAURA) && isConst?(type,PBTypes,:DARK)) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && isConst?(type,PBTypes,:FAIRY))
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
if @battle.pbCheckGlobalAbility(:AURABREAK)
multipliers[BASE_DMG_MULT] *= 2/3.0
else
@@ -311,11 +308,11 @@ class PokeBattle_Move
if user.effects[PBEffects::HelpingHand] && !self.is_a?(PokeBattle_Confusion)
multipliers[BASE_DMG_MULT] *= 1.5
end
if user.effects[PBEffects::Charge]>0 && isConst?(type,PBTypes,:ELECTRIC)
if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC
multipliers[BASE_DMG_MULT] *= 2
end
# Mud Sport
if isConst?(type,PBTypes,:ELECTRIC)
if type == :ELECTRIC
@battle.eachBattler do |b|
next if !b.effects[PBEffects::MudSport]
multipliers[BASE_DMG_MULT] /= 3
@@ -326,7 +323,7 @@ class PokeBattle_Move
end
end
# Water Sport
if isConst?(type,PBTypes,:FIRE)
if type == :FIRE
@battle.eachBattler do |b|
next if !b.effects[PBEffects::WaterSport]
multipliers[BASE_DMG_MULT] /= 3
@@ -340,21 +337,15 @@ class PokeBattle_Move
if user.affectedByTerrain?
case @battle.field.terrain
when PBBattleTerrains::Electric
if isConst?(type,PBTypes,:ELECTRIC)
multipliers[BASE_DMG_MULT] *= 1.5
end
multipliers[BASE_DMG_MULT] *= 1.5 if type == :ELECTRIC
when PBBattleTerrains::Grassy
if isConst?(type,PBTypes,:GRASS)
multipliers[BASE_DMG_MULT] *= 1.5
end
multipliers[BASE_DMG_MULT] *= 1.5 if type == :GRASS
when PBBattleTerrains::Psychic
if isConst?(type,PBTypes,:PSYCHIC)
multipliers[BASE_DMG_MULT] *= 1.5
end
multipliers[BASE_DMG_MULT] *= 1.5 if type == :PSYCHIC
end
end
if @battle.field.terrain==PBBattleTerrains::Misty && target.affectedByTerrain? &&
isConst?(type,PBTypes,:DRAGON)
type == :DRAGON
multipliers[BASE_DMG_MULT] /= 2
end
# Badge multipliers
@@ -381,15 +372,15 @@ class PokeBattle_Move
# Weather
case @battle.pbWeather
when PBWeather::Sun, PBWeather::HarshSun
if isConst?(type,PBTypes,:FIRE)
if type == :FIRE
multipliers[FINAL_DMG_MULT] *= 1.5
elsif isConst?(type,PBTypes,:WATER)
elsif type == :WATER
multipliers[FINAL_DMG_MULT] /= 2
end
when PBWeather::Rain, PBWeather::HeavyRain
if isConst?(type,PBTypes,:FIRE)
if type == :FIRE
multipliers[FINAL_DMG_MULT] /= 2
elsif isConst?(type,PBTypes,:WATER)
elsif type == :WATER
multipliers[FINAL_DMG_MULT] *= 1.5
end
when PBWeather::Sandstorm
@@ -411,7 +402,7 @@ class PokeBattle_Move
multipliers[FINAL_DMG_MULT] *= random/100.0
end
# STAB
if type>=0 && user.pbHasType?(type)
if type && user.pbHasType?(type)
if user.hasActiveAbility?(:ADAPTABILITY)
multipliers[FINAL_DMG_MULT] *= 2
else

View File

@@ -34,7 +34,7 @@ class PokeBattle_Confusion < PokeBattle_Move
@priority = 0
@flags = ""
@addlEffect = 0
@calcType = -1
@calcType = nil
@powerBoost = false
@snatched = false
end
@@ -66,7 +66,7 @@ class PokeBattle_Struggle < PokeBattle_Move
@priority = 0
@flags = ""
@addlEffect = 0
@calcType = -1
@calcType = nil
@powerBoost = false
@snatched = false
end
@@ -636,6 +636,7 @@ class PokeBattle_PledgeMove < PokeBattle_Move
@battle.pbDisplay(_INTL("The two moves have become one! It's a combined move!"))
@pledgeCombo = true
@comboEffect = i[1]; @overrideType = i[2]; @overrideAnim = i[3]
@overrideType = nil if !GameData::Type.exists?(@overrideType)
break
end
return if @pledgeCombo

View File

@@ -113,7 +113,7 @@ class PokeBattle_Move_007 < PokeBattle_ParalysisMove
end
def pbFailsAgainstTarget?(user,target)
if @id == :THUNDERWAVE && PBTypes.ineffective?(target.damageState.typeMod)
if @id == :THUNDERWAVE && PBTypeEffectiveness.ineffective?(target.damageState.typeMod)
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
return true
end
@@ -1709,7 +1709,7 @@ class PokeBattle_Move_05C < PokeBattle_Move
if !lastMoveData ||
user.pbHasMove?(target.lastRegularMoveUsed) ||
@moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
lastMoveData.type == :SHADOW
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1759,7 +1759,7 @@ class PokeBattle_Move_05D < PokeBattle_Move
if !lastMoveData ||
user.pbHasMove?(target.lastRegularMoveUsed) ||
@moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
lastMoveData.type = :SHADOW
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1810,7 +1810,7 @@ class PokeBattle_Move_05E < PokeBattle_Move
def pbEffectGeneral(user)
newType = @newTypes[@battle.pbRandom(@newTypes.length)]
user.pbChangeTypes(newType)
typeName = PBTypes.getName(newType)
typeName = GameData::Item.get(newType).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName))
end
end
@@ -1824,7 +1824,7 @@ end
class PokeBattle_Move_05F < PokeBattle_Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1832,20 +1832,19 @@ class PokeBattle_Move_05F < PokeBattle_Move
return false
end
def pbFailsAgainstTarget?(user,target)
if !target.lastMoveUsed || target.lastMoveUsedType < 0 ||
PBTypes.isPseudoType?(GameData::Move.get(target.lastMoveUsed).type)
def pbFailsAgainstTarget?(user, target)
if !target.lastMoveUsed || !target.lastMoveUsedType ||
PBTypes.isPseudoType?(target.lastMoveUsedType)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@newTypes = []
for i in 0..PBTypes.maxValue
next if PBTypes.isPseudoType?(i)
next if user.pbHasType?(i)
next if !PBTypes.resistant?(target.lastMoveUsedType,i)
@newTypes.push(i)
GameData::Type.each do |t|
next if t.pseudo_type || user.pbHasType?(t.id) ||
!PBTypes.resistant?(target.lastMoveUsedType, t.id)
@newTypes.push(t.id)
end
if @newTypes.length==0
if @newTypes.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1855,8 +1854,8 @@ class PokeBattle_Move_05F < PokeBattle_Move
def pbEffectGeneral(user)
newType = @newTypes[@battle.pbRandom(@newTypes.length)]
user.pbChangeTypes(newType)
typeName = PBTypes.getName(newType)
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName))
typeName = GameData::Type.get(newType).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", user.pbThis, typeName))
end
end
@@ -1871,49 +1870,59 @@ class PokeBattle_Move_060 < PokeBattle_Move
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@newType = getID(PBTypes,:NORMAL)
@newType = :NORMAL
checkedTerrain = false
case @battle.field.terrain
when PBBattleTerrains::Electric
if hasConst?(PBTypes,:ELECTRIC)
@newType = getID(PBTypes,:ELECTRIC); checkedTerrain = true
if GameData::Type.exists?(:ELECTRIC)
@newType = :ELECTRIC
checkedTerrain = true
end
when PBBattleTerrains::Grassy
if hasConst?(PBTypes,:GRASS)
@newType = getID(PBTypes,:GRASS); checkedTerrain = true
if GameData::Type.exists?(:GRASS)
@newType = :GRASS
checkedTerrain = true
end
when PBBattleTerrains::Misty
if hasConst?(PBTypes,:FAIRY)
@newType = getID(PBTypes,:FAIRY); checkedTerrain = true
if GameData::Type.exists?(:FAIRY)
@newType = :FAIRY
checkedTerrain = true
end
when PBBattleTerrains::Psychic
if hasConst?(PBTypes,:PSYCHIC)
@newType = getID(PBTypes,:PSYCHIC); checkedTerrain = true
if GameData::Type.exists?(:PSYCHIC)
@newType = :PSYCHIC
checkedTerrain = true
end
end
if !checkedTerrain
case @battle.environment
when PBEnvironment::Grass then @newType = getID(PBTypes,:GRASS)
when PBEnvironment::TallGrass then @newType = getID(PBTypes,:GRASS)
when PBEnvironment::MovingWater then @newType = getID(PBTypes,:WATER)
when PBEnvironment::StillWater then @newType = getID(PBTypes,:WATER)
when PBEnvironment::Puddle then @newType = getID(PBTypes,:WATER)
when PBEnvironment::Underwater then @newType = getID(PBTypes,:WATER)
when PBEnvironment::Cave then @newType = getID(PBTypes,:ROCK)
when PBEnvironment::Rock then @newType = getID(PBTypes,:GROUND)
when PBEnvironment::Sand then @newType = getID(PBTypes,:GROUND)
when PBEnvironment::Forest then @newType = getID(PBTypes,:BUG)
when PBEnvironment::ForestGrass then @newType = getID(PBTypes,:BUG)
when PBEnvironment::Snow then @newType = getID(PBTypes,:ICE)
when PBEnvironment::Ice then @newType = getID(PBTypes,:ICE)
when PBEnvironment::Volcano then @newType = getID(PBTypes,:FIRE)
when PBEnvironment::Graveyard then @newType = getID(PBTypes,:GHOST)
when PBEnvironment::Sky then @newType = getID(PBTypes,:FLYING)
when PBEnvironment::Space then @newType = getID(PBTypes,:DRAGON)
when PBEnvironment::UltraSpace then @newType = getID(PBTypes,:PSYCHIC)
when PBEnvironment::Grass, PBEnvironment::TallGrass
@newType = :GRASS
when PBEnvironment::MovingWater, PBEnvironment::StillWater,
PBEnvironment::Puddle, PBEnvironment::Underwater
@newType = :WATER
when PBEnvironment::Cave
@newType = :ROCK
when PBEnvironment::Rock, PBEnvironment::Sand
@newType = :GROUND
when PBEnvironment::Forest, PBEnvironment::ForestGrass
@newType = :BUG
when PBEnvironment::Snow, PBEnvironment::Ice
@newType = :ICE
when PBEnvironment::Volcano
@newType = :FIRE
when PBEnvironment::Graveyard
@newType = :GHOST
when PBEnvironment::Sky
@newType = :FLYING
when PBEnvironment::Space
@newType = :DRAGON
when PBEnvironment::UltraSpace
@newType = :PSYCHIC
end
end
if !user.pbHasOtherType?(@newType)
@newType = :NORMAL if !GameData::Type.exists?(@newType)
if !GameData::Type.exists?(@newType) || !user.pbHasOtherType?(@newType)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1922,7 +1931,7 @@ class PokeBattle_Move_060 < PokeBattle_Move
def pbEffectGeneral(user)
user.pbChangeTypes(@newType)
typeName = PBTypes.getName(@newType)
typeName = GameData::Type.get(@newType).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typeName))
end
end
@@ -1934,8 +1943,8 @@ end
#===============================================================================
class PokeBattle_Move_061 < PokeBattle_Move
def pbFailsAgainstTarget?(user,target)
if !target.canChangeType? ||
!target.pbHasOtherType?(getConst(PBTypes,:WATER))
if !target.canChangeType? || !GameData::Type.exists?(:WATER) ||
!target.pbHasOtherType?(:WATER)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1943,9 +1952,8 @@ class PokeBattle_Move_061 < PokeBattle_Move
end
def pbEffectAgainstTarget(user,target)
newType = getConst(PBTypes,:WATER)
target.pbChangeTypes(newType)
typeName = PBTypes.getName(newType)
target.pbChangeTypes(:WATER)
typeName = GameData::Type.get(:WATER).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
end
end
@@ -2362,8 +2370,7 @@ class PokeBattle_Move_070 < PokeBattle_FixedDamageMove
@battle.pbHideAbilitySplash(target)
return true
end
if NEWEST_BATTLE_MECHANICS &&
isConst?(target.damageState.typeMod,PBTypes,:ICE) && target.pbHasType?(:ICE)
if NEWEST_BATTLE_MECHANICS && @id == :SHEERCOLD && target.pbHasType?(:ICE)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end

View File

@@ -110,26 +110,26 @@ class PokeBattle_Move_087 < PokeBattle_Move
end
def pbBaseType(user)
ret = getID(PBTypes,:NORMAL)
ret = :NORMAL
case @battle.pbWeather
when PBWeather::Sun, PBWeather::HarshSun
ret = getConst(PBTypes,:FIRE) || ret
ret = :FIRE if GameData::Type.exists?(:FIRE)
when PBWeather::Rain, PBWeather::HeavyRain
ret = getConst(PBTypes,:WATER) || ret
ret = :WATER if GameData::Type.exists?(:WATER)
when PBWeather::Sandstorm
ret = getConst(PBTypes,:ROCK) || ret
ret = :ROCK if GameData::Type.exists?(:ROCK)
when PBWeather::Hail
ret = getConst(PBTypes,:ICE) || ret
ret = :ICE if GameData::Type.exists?(:ICE)
end
return ret
end
def pbShowAnimation(id,user,targets,hitNum=0,showAnimation=true)
t = pbBaseType(user)
hitNum = 1 if isConst?(t,PBTypes,:FIRE) # Type-specific anims
hitNum = 2 if isConst?(t,PBTypes,:WATER)
hitNum = 3 if isConst?(t,PBTypes,:ROCK)
hitNum = 4 if isConst?(t,PBTypes,:ICE)
hitNum = 1 if t == :FIRE # Type-specific anims
hitNum = 2 if t == :WATER
hitNum = 3 if t == :ROCK
hitNum = 4 if t == :ICE
super
end
end
@@ -262,11 +262,8 @@ def pbHiddenPower(pkmn)
iv = pkmn.iv
idxType = 0; power = 60
types = []
for i in 0..PBTypes.maxValue
next if PBTypes.isPseudoType?(i)
next if isConst?(i,PBTypes,:NORMAL) || isConst?(i,PBTypes,:SHADOW)
types.push(i)
end
GameData::Type.each { |t| types.push(t.id) if !t.pseudo_type && ![:NORMAL, :SHADOW].include?(t.id)}
types.sort! { |a, b| GameData::Type.get(a).id_number <=> GameData::Type.get(b).id_number }
idxType |= (iv[PBStats::HP]&1)
idxType |= (iv[PBStats::ATTACK]&1)<<1
idxType |= (iv[PBStats::DEFENSE]&1)<<2
@@ -491,10 +488,10 @@ class PokeBattle_Move_096 < PokeBattle_Move
# the AI won't want to use it if the user has no item anyway, and
# complex item movement is unlikely, perhaps this is good enough.
def pbBaseType(user)
ret = getID(PBTypes,:NORMAL)
ret = :NORMAL
@typeArray.each do |type, items|
next if !items.include?(@berry.id)
ret = getConst(PBTypes,type) || ret
ret = type if GameData::Type.exists?(type)
break
end
return ret
@@ -765,12 +762,11 @@ class PokeBattle_Move_09F < PokeBattle_Move
end
def pbBaseType(user)
ret = getID(PBTypes,:NORMAL)
ret = :NORMAL
if user.itemActive?
@itemTypes.each do |item, itemType|
next if user.item != item
t = getConst(PBTypes,itemType)
ret = t || ret
ret = itemType if GameData::Type.exists?(itemType)
break
end
end
@@ -781,10 +777,10 @@ class PokeBattle_Move_09F < PokeBattle_Move
if @id == :TECHNOBLAST # Type-specific anim
t = pbBaseType(user)
hitNum = 0
hitNum = 1 if isConst?(t,PBTypes,:ELECTRIC)
hitNum = 2 if isConst?(t,PBTypes,:FIRE)
hitNum = 3 if isConst?(t,PBTypes,:ICE)
hitNum = 4 if isConst?(t,PBTypes,:WATER)
hitNum = 1 if t == :ELECTRIC
hitNum = 2 if t == :FIRE
hitNum = 3 if t == :ICE
hitNum = 4 if t == :WATER
end
super
end
@@ -1551,7 +1547,7 @@ class PokeBattle_Move_0B5 < PokeBattle_Move
next if NEWEST_BATTLE_MECHANICS && pkmn.egg?
pkmn.moves.each do |move|
next if @moveBlacklist.include?(move.function_code)
next if isConst?(move.type,PBTypes,:SHADOW)
next if move.type == :SHADOW
@assistMoves.push(move.id)
end
end
@@ -1670,7 +1666,7 @@ class PokeBattle_Move_0B6 < PokeBattle_Move
move_data = GameData::Move.get(move_id)
next if @moveBlacklist.include?(move_data.function_code)
next if @moveBlacklistSignatures.include?(move_data.id)
next if isConst?(move_data.type, PBTypes, :SHADOW)
next if move_data.type == :SHADOW
@metronomeMove = move_data.id
break
end

View File

@@ -107,8 +107,8 @@ class PokeBattle_Move_106 < PokeBattle_PledgeMove
def initialize(battle,move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["107", :SeaOfFire, getConst(PBTypes, :FIRE), :FIREPLEDGE],
["108", :Swamp, nil, nil]]
@combos = [["107", :SeaOfFire, :FIRE, :FIREPLEDGE],
["108", :Swamp, nil, nil]]
end
end
@@ -123,8 +123,8 @@ class PokeBattle_Move_107 < PokeBattle_PledgeMove
def initialize(battle,move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["108", :Rainbow, getConst(PBTypes, :WATER), :WATERPLEDGE],
["106", :SeaOfFire, nil, nil]]
@combos = [["108", :Rainbow, :WATER, :WATERPLEDGE],
["106", :SeaOfFire, nil, nil]]
end
end
@@ -139,8 +139,8 @@ class PokeBattle_Move_108 < PokeBattle_PledgeMove
def initialize(battle,move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["106", :Swamp, getConst(PBTypes, :GRASS), :GRASSPLEDGE],
["107", :Rainbow, nil, nil]]
@combos = [["106", :Swamp, :GRASS, :GRASSPLEDGE],
["107", :Rainbow, nil, nil]]
end
end
@@ -768,8 +768,7 @@ class PokeBattle_Move_11C < PokeBattle_Move
def hitsFlyingTargets?; return true; end
def pbCalcTypeModSingle(moveType,defType,user,target)
return PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(moveType,PBTypes,:GROUND) &&
isConst?(defType,PBTypes,:FLYING)
return PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING
return super
end
@@ -1065,7 +1064,7 @@ end
#===============================================================================
class PokeBattle_Move_135 < PokeBattle_FreezeMove
def pbCalcTypeModSingle(moveType,defType,user,target)
return PBTypeEffectiveness::SUPER_EFFECTIVE_ONE if isConst?(defType,PBTypes,:WATER)
return PBTypeEffectiveness::SUPER_EFFECTIVE_ONE if defType == :WATER
return super
end
end
@@ -1402,7 +1401,7 @@ end
#===============================================================================
class PokeBattle_Move_142 < PokeBattle_Move
def pbFailsAgainstTarget?(user,target)
if !hasConst?(PBTypes,:GHOST) || target.pbHasType?(:GHOST) || !target.canChangeType?
if !GameData::Type.exists?(:GHOST) || target.pbHasType?(:GHOST) || !target.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1410,9 +1409,8 @@ class PokeBattle_Move_142 < PokeBattle_Move
end
def pbEffectAgainstTarget(user,target)
ghostType = getConst(PBTypes,:GHOST)
target.effects[PBEffects::Type3] = ghostType
typeName = PBTypes.getName(ghostType)
target.effects[PBEffects::Type3] = :GHOST
typeName = GameData::Type.get(:GHOST).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
end
end
@@ -1424,7 +1422,7 @@ end
#===============================================================================
class PokeBattle_Move_143 < PokeBattle_Move
def pbFailsAgainstTarget?(user,target)
if !hasConst?(PBTypes,:GRASS) || target.pbHasType?(:GRASS) || !target.canChangeType?
if !GameData::Type.exists?(:GRASS) || target.pbHasType?(:GRASS) || !target.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1432,9 +1430,8 @@ class PokeBattle_Move_143 < PokeBattle_Move
end
def pbEffectAgainstTarget(user,target)
grassType = getConst(PBTypes,:GRASS)
target.effects[PBEffects::Type3] = grassType
typeName = PBTypes.getName(grassType)
target.effects[PBEffects::Type3] = :GRASS
typeName = GameData::Type.get(:GRASS).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
end
end
@@ -1455,9 +1452,9 @@ class PokeBattle_Move_144 < PokeBattle_Move
def pbCalcTypeModSingle(moveType,defType,user,target)
ret = super
if hasConst?(PBTypes,:FLYING)
flyingEff = PBTypes.getEffectiveness(getConst(PBTypes,:FLYING),defType)
ret *= flyingEff.to_f/PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
if GameData::Type.exists?(:FLYING)
flyingEff = PBTypes.getEffectiveness(:FLYING, defType)
ret *= flyingEff.to_f / PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
end
return ret
end
@@ -2254,7 +2251,7 @@ end
class PokeBattle_Move_169 < PokeBattle_Move
def pbBaseType(user)
userTypes = user.pbTypes(true)
return (userTypes.length==0) ? -1 : userTypes[0]
return userTypes[0]
end
end

View File

@@ -347,11 +347,11 @@ class PokeBattle_Battle
end
# Entry hazards
# Stealth Rock
if battler.pbOwnSide.effects[PBEffects::StealthRock] && battler.takesIndirectDamage?
aType = getConst(PBTypes,:ROCK) || 0
if battler.pbOwnSide.effects[PBEffects::StealthRock] && battler.takesIndirectDamage? &&
GameData::Type.exists?(:ROCK)
bTypes = battler.pbTypes(true)
eff = PBTypes.getCombinedEffectiveness(aType,bTypes[0],bTypes[1],bTypes[2])
if !PBTypes.ineffective?(eff)
eff = PBTypes.getCombinedEffectiveness(:ROCK, bTypes[0], bTypes[1], bTypes[2])
if !PBTypeEffectiveness.ineffective?(eff)
eff = eff.to_f/PBTypeEffectiveness::NORMAL_EFFECTIVE
oldHP = battler.hp
battler.pbReduceHP(battler.totalhp*eff/8,false)

View File

@@ -22,7 +22,7 @@ class PokeBattle_AI
moveData = GameData::Move.get(target.lastMoveUsed)
moveType = moveData.type
typeMod = pbCalcTypeMod(moveType,target,battler)
if PBTypes.superEffective?(typeMod) && moveData.base_damage > 50
if PBTypeEffectiveness.superEffective?(typeMod) && moveData.base_damage > 50
switchChance = (moveData.base_damage > 70) ? 30 : 20
shouldSwitch = (pbAIRandom(100) < switchChance)
end
@@ -107,18 +107,18 @@ class PokeBattle_AI
end
end
# moveType is the type of the target's last used move
if moveType>=0 && PBTypes.ineffective?(pbCalcTypeMod(moveType,battler,battler))
if moveType>=0 && PBTypeEffectiveness.ineffective?(pbCalcTypeMod(moveType,battler,battler))
weight = 65
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
if PBTypes.superEffective?(typeMod.to_f/PBTypeEffectivenesss::NORMAL_EFFECTIVE)
if PBTypeEffectiveness.superEffective?(typeMod.to_f/PBTypeEffectivenesss::NORMAL_EFFECTIVE)
# Greater weight if new Pokemon's type is effective against target
weight = 85
end
list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first
elsif moveType>=0 && PBTypes.resistant?(pbCalcTypeMod(moveType,battler,battler))
elsif moveType>=0 && PBTypeEffectiveness.resistant?(pbCalcTypeMod(moveType,battler,battler))
weight = 40
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
if PBTypes.superEffective?(typeMod.to_f/PBTypeEffectivenesss::NORMAL_EFFECTIVE)
if PBTypeEffectiveness.superEffective?(typeMod.to_f/PBTypeEffectivenesss::NORMAL_EFFECTIVE)
# Greater weight if new Pokemon's type is effective against target
weight = 60
end

View File

@@ -71,7 +71,7 @@ class PokeBattle_AI
if target.pbCanParalyze?(user,false) &&
!(skill>=PBTrainerAI.mediumSkill &&
move.id == :THUNDERWAVE &&
PBTypes.ineffective?(pbCalcTypeMod(move.type,user,target)))
PBTypeEffectiveness.ineffective?(pbCalcTypeMod(move.type,user,target)))
score += 30
if skill>=PBTrainerAI.mediumSkill
aspeed = pbRoughStat(user,PBStats::SPEED,skill)
@@ -323,7 +323,7 @@ class PokeBattle_AI
when "021"
foundMove = false
user.eachMove do |m|
next if !isConst?(m.type,PBTypes,:ELECTRIC) || !m.damagingMove?
next if m.type != :ELECTRIC || !m.damagingMove?
foundMove = true
break
end
@@ -1280,7 +1280,7 @@ class PokeBattle_AI
else
lastMoveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
lastMoveData.type == :SHADOW
score -= 90
end
user.eachMove do |m|
@@ -1301,7 +1301,7 @@ class PokeBattle_AI
else
lastMoveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
lastMoveData.type == :SHADOW
score -= 90
end
user.eachMove do |m|
@@ -1328,23 +1328,23 @@ class PokeBattle_AI
when "05F"
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
score -= 90
elsif !target.lastMoveUsed ||
PBTypes.isPseudoType?(GameData::Move.get(target.lastMoveUsed).type)
elsif !target.lastMoveUsed || GameData::Move.get(target.lastMoveUsed).pseudo_type
score -= 90
else
aType = -1
aType = nil
target.eachMove do |m|
next if m.id!=target.lastMoveUsed
aType = m.pbCalcType(user)
break
end
if aType<0
if !aType
score -= 90
else
types = []
for i in 0..PBTypes.maxValue
next if user.pbHasType?(i)
types.push(i) if PBTypes.resistant?(aType,i)
GameData::Type.each do |t|
next if t.pseudo_type || user.pbHasType?(t.id) ||
!PBTypes.resistant?(aType, t.id)
types.push(t.id)
end
score -= 90 if types.length==0
end
@@ -1532,7 +1532,7 @@ class PokeBattle_AI
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed
moveData = GameData::Move.get(target.lastMoveUsed)
if moveData.base_damage > 0 &&
(MOVE_CATEGORY_PER_MOVE && moveData.caegory == 1) ||
(MOVE_CATEGORY_PER_MOVE && moveData.category == 1) ||
(!MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData.type))
score -= 60
end
@@ -1780,7 +1780,7 @@ class PokeBattle_AI
score += 60
elsif moveData.category != 2 && # Damaging move
moveData.target == PBTargets::NearOther &&
PBTypes.ineffective?(pbCalcTypeMod(moveData.type, target, user))
PBTypeEffectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
score += 60
end
end
@@ -2147,7 +2147,7 @@ class PokeBattle_AI
score -= 90
else
user.eachMove do |m|
next if !m.damagingMove? || !isConst?(m.type,PBTypes,:FIRE)
next if !m.damagingMove? || m.type != :FIRE
score += 20
end
end
@@ -2160,7 +2160,7 @@ class PokeBattle_AI
score -= 90
else
user.eachMove do |m|
next if !m.damagingMove? || !isConst?(m.type,PBTypes,:WATER)
next if !m.damagingMove? || m.type != :WATER
score += 20
end
end

View File

@@ -35,30 +35,29 @@ class PokeBattle_AI
end
# Foresight
if user.hasActiveAbility?(:SCRAPPY) || target.effects[PBEffects::Foresight]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:GHOST) &&
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :GHOST &&
PBTypes.ineffective?(moveType,defType)
end
# Miracle Eye
if target.effects[PBEffects::MiracleEye]
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:DARK) &&
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :DARK &&
PBTypes.ineffective?(moveType,defType)
end
# Delta Stream's weather
if @battle.pbWeather==PBWeather::StrongWinds
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:FLYING) &&
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING &&
PBTypes.superEffective?(moveType,defType)
end
# Grounded Flying-type Pokémon become susceptible to Ground moves
if !target.airborne?
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if isConst?(defType,PBTypes,:FLYING) &&
isConst?(moveType,PBTypes,:GROUND)
ret = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if defType == :FLYING && moveType == :GROUND
end
return ret
end
def pbCalcTypeMod(moveType,user,target)
return PBTypeEffectiveness::NORMAL_EFFECTIVE if moveType<0
return PBTypeEffectiveness::NORMAL_EFFECTIVE if isConst?(moveType,PBTypes,:GROUND) &&
return PBTypeEffectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) && target.hasActiveItem?(:IRONBALL)
# Determine types
tTypes = target.pbTypes(true)
@@ -91,21 +90,22 @@ class PokeBattle_AI
type = pbRoughType(move,user,skill)
typeMod = pbCalcTypeMod(type,user,target)
# Type effectiveness
return true if PBTypes.ineffective?(typeMod) || score<=0
return true if PBTypeEffectiveness.ineffective?(typeMod) || score<=0
# Immunity due to ability/item/other effects
if skill>=PBTrainerAI.mediumSkill
if isConst?(move.type,PBTypes,:GROUND)
case move.type
when :GROUND
return true if target.airborne? && !move.hitsFlyingTargets?
elsif isConst?(move.type,PBTypes,:FIRE)
when :FIRE
return true if target.hasActiveAbility?(:FLASHFIRE)
elsif isConst?(move.type,PBTypes,:WATER)
when :WATER
return true if target.hasActiveAbility?([:DRYSKIN,:STORMDRAIN,:WATERABSORB])
elsif isConst?(move.type,PBTypes,:GRASS)
when :GRASS
return true if target.hasActiveAbility?(:SAPSIPPER)
elsif isConst?(move.type,PBTypes,:ELECTRIC)
when :ELECTRIC
return true if target.hasActiveAbility?([:LIGHTNINGROD,:MOTORDRIVE,:VOLTABSORB])
end
return true if PBTypes.notVeryEffective?(typeMod) &&
return true if PBTypeEffectiveness.notVeryEffective?(typeMod) &&
target.hasActiveAbility?(:WONDERGUARD)
return true if move.damagingMove? && user.index!=target.index && !target.opposes?(user) &&
target.hasActiveAbility?(:TELEPATHY)
@@ -227,15 +227,14 @@ class PokeBattle_AI
when "0E1" # Final Gambit
baseDmg = user.hp
when "144" # Flying Press
type = getConst(PBTypes,:FLYING) || -1
if type>=0
if GameData::Type.exists?(:FLYING)
if skill>=PBTrainerAI.highSkill
targetTypes = target.pbTypes(true)
mult = PBTypes.getCombinedEffectiveness(type,
mult = PBTypes.getCombinedEffectiveness(:FLYING,
targetTypes[0],targetTypes[1],targetTypes[2])
baseDmg = (baseDmg.to_f*mult/PBTypeEffectiveness::NORMAL_EFFECTIVE).round
else
mult = PBTypes.getCombinedEffectiveness(type,
mult = PBTypes.getCombinedEffectiveness(:FLYING,
target.type1,target.type2,target.effects[PBEffects::Type3])
baseDmg = (baseDmg.to_f*mult/PBTypeEffectiveness::NORMAL_EFFECTIVE).round
end
@@ -347,8 +346,8 @@ class PokeBattle_AI
end
# Global abilities
if skill>=PBTrainerAI.mediumSkill
if (@battle.pbCheckGlobalAbility(:DARKAURA) && isConst?(type,PBTypes,:DARK)) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && isConst?(type,PBTypes,:FAIRY))
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
if @battle.pbCheckGlobalAbility(:AURABREAK)
multipliers[BASE_DMG_MULT] *= 2/3
else
@@ -365,13 +364,13 @@ class PokeBattle_AI
# Helping Hand - n/a
# Charge
if skill>=PBTrainerAI.mediumSkill
if user.effects[PBEffects::Charge]>0 && isConst?(type,PBTypes,:ELECTRIC)
if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC
multipliers[BASE_DMG_MULT] *= 2
end
end
# Mud Sport and Water Sport
if skill>=PBTrainerAI.mediumSkill
if isConst?(type,PBTypes,:ELECTRIC)
if type == :ELECTRIC
@battle.eachBattler do |b|
next if !b.effects[PBEffects::MudSport]
multipliers[BASE_DMG_MULT] /= 3
@@ -381,7 +380,7 @@ class PokeBattle_AI
multipliers[BASE_DMG_MULT] /= 3
end
end
if isConst?(type,PBTypes,:FIRE)
if type == :FIRE
@battle.eachBattler do |b|
next if !b.effects[PBEffects::WaterSport]
multipliers[BASE_DMG_MULT] /= 3
@@ -396,21 +395,15 @@ class PokeBattle_AI
if user.affectedByTerrain? && skill>=PBTrainerAI.mediumSkill
case @battle.field.terrain
when PBBattleTerrains::Electric
if isConst?(type,PBTypes,:ELECTRIC)
multipliers[BASE_DMG_MULT] *= 1.5
end
multipliers[BASE_DMG_MULT] *= 1.5 if type == :ELECTRIC
when PBBattleTerrains::Grassy
if isConst?(type,PBTypes,:GRASS)
multipliers[BASE_DMG_MULT] *= 1.5
end
multipliers[BASE_DMG_MULT] *= 1.5 if type == :GRASS
when PBBattleTerrains::Psychic
if isConst?(type,PBTypes,:PSYCHIC)
multipliers[BASE_DMG_MULT] *= 1.5
end
multipliers[BASE_DMG_MULT] *= 1.5 if type == :PSYCHIC
end
end
if target.affectedByTerrain? && skill>=PBTrainerAI.mediumSkill
if @battle.field.terrain==PBBattleTerrains::Misty && isConst?(type,PBTypes,:DRAGON)
if @battle.field.terrain==PBBattleTerrains::Misty && type == :DRAGON
multipliers[BASE_DMG_MULT] /= 2
end
end
@@ -438,15 +431,15 @@ class PokeBattle_AI
if skill>=PBTrainerAI.mediumSkill
case @battle.pbWeather
when PBWeather::Sun, PBWeather::HarshSun
if isConst?(type,PBTypes,:FIRE)
if type == :FIRE
multipliers[FINAL_DMG_MULT] *= 1.5
elsif isConst?(type,PBTypes,:WATER)
elsif type == :WATER
multipliers[FINAL_DMG_MULT] /= 2
end
when PBWeather::Rain, PBWeather::HeavyRain
if isConst?(type,PBTypes,:FIRE)
if type == :FIRE
multipliers[FINAL_DMG_MULT] /= 2
elsif isConst?(type,PBTypes,:WATER)
elsif type == :WATER
multipliers[FINAL_DMG_MULT] *= 1.5
end
when PBWeather::Sandstorm
@@ -459,7 +452,7 @@ class PokeBattle_AI
# Random variance - n/a
# STAB
if skill>=PBTrainerAI.mediumSkill
if type>=0 && user.pbHasType?(type)
if type && user.pbHasType?(type)
if user.hasActiveAbility?(:ADAPTABILITY)
multipliers[FINAL_DMG_MULT] *= 2
else
@@ -547,7 +540,7 @@ class PokeBattle_AI
if c>=0
c += 1 if move.highCriticalRate?
c += user.effects[PBEffects::FocusEnergy]
c += 1 if user.inHyperMode? && isConst?(move.type,PBTypes,:SHADOW)
c += 1 if user.inHyperMode? && move.type == :SHADOW
end
if c>=0
c = 4 if c>4

View File

@@ -384,7 +384,7 @@ class FightMenuDisplay < BattleMenuBase
def refreshMoveData(move)
# Write PP and type of the selected move
if !USE_GRAPHICS
moveType = PBTypes.getName(move.type)
moveType = GameData::Type.get(move.type).name
if move.total_pp<=0
@msgBox.text = _INTL("PP: ---<br>TYPE/{1}",moveType)
else
@@ -400,7 +400,8 @@ class FightMenuDisplay < BattleMenuBase
end
@visibility["typeIcon"] = true
# Type icon
@typeIcon.src_rect.y = move.type*TYPE_ICON_HEIGHT
type_number = GameData::Type.get(move.type).id_number
@typeIcon.src_rect.y = type_number * TYPE_ICON_HEIGHT
# PP text
if move.total_pp>0
ppFraction = [(4.0*move.pp/move.total_pp).ceil,3].min

View File

@@ -4,7 +4,7 @@ class PokeBattle_Scene
# Return values: -1=Cancel, 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
#=============================================================================
def pbCommandMenu(idxBattler,firstAction)
shadowTrainer = (hasConst?(PBTypes,:SHADOW) && @battle.trainerBattle?)
shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?)
cmds = [
_INTL("What will\n{1} do?",@battle.battlers[idxBattler].name),
_INTL("Fight"),

View File

@@ -437,20 +437,17 @@ class PokeBattle_Scene
:DARK => [:PURSUIT, :DARKPULSE, :HONECLAWS, nil, :SNARL, :EMBARGO],
:FAIRY => [:TACKLE, :FAIRYWIND, :MOONLIGHT, nil, :SWIFT, :SWEETKISS]
}
typeDefaultAnim.each do |type, anims|
next if !isConst?(moveType, PBTypes, type)
if typeDefaultAnim[moveType]
anims = typeDefaultAnim[moveType]
if GameData::Move.exists?(anims[moveKind])
anim = pbFindMoveAnimDetails(move2anim, anims[moveKind], idxUser)
end
break if anim
if moveKind >= 3 && GameData::Move.exists?(anims[moveKind - 3])
if !anim && moveKind >= 3 && GameData::Move.exists?(anims[moveKind - 3])
anim = pbFindMoveAnimDetails(move2anim, anims[moveKind - 3], idxUser)
end
break if anim
if GameData::Move.exists?(anims[2])
if !anim && GameData::Move.exists?(anims[2])
anim = pbFindMoveAnimDetails(move2anim, anims[2], idxUser)
end
break
end
return anim if anim
# Default animation for the move's type not found, use Tackle's animation

View File

@@ -528,7 +528,7 @@ end
# one of the ability's bearer's stats instead.
def pbBattleMoveImmunityStatAbility(user,target,move,moveType,immuneType,stat,increment,battle)
return false if user.index==target.index
return false if !isConst?(moveType,PBTypes,immuneType)
return false if moveType != immuneType
battle.pbShowAbilitySplash(target)
if target.pbCanRaiseStatStage?(stat,target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@@ -552,7 +552,7 @@ end
# ability's bearer by 1/4 of its total HP instead.
def pbBattleMoveImmunityHealAbility(user,target,move,moveType,immuneType,battle)
return false if user.index==target.index
return false if !isConst?(moveType,PBTypes,immuneType)
return false if moveType != immuneType
battle.pbShowAbilitySplash(target)
if target.canHeal? && target.pbRecoverHP(target.totalhp/4)>0
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@@ -575,7 +575,7 @@ end
def pbBattleGem(user,type,move,mults,moveType)
# Pledge moves never consume Gems
return if move.is_a?(PokeBattle_PledgeMove)
return if !isConst?(moveType,PBTypes,type)
return if moveType != type
user.effects[PBEffects::GemConsumed] = user.item_id
if NEWEST_BATTLE_MECHANICS
mults[BASE_DMG_MULT] *= 1.3
@@ -585,8 +585,8 @@ def pbBattleGem(user,type,move,mults,moveType)
end
def pbBattleTypeWeakingBerry(type,moveType,target,mults)
return if !isConst?(moveType,PBTypes,type)
return if PBTypes.resistant?(target.damageState.typeMod) && !isConst?(moveType,PBTypes,:NORMAL)
return if moveType != type
return if PBTypeEffectiveness.resistant?(target.damageState.typeMod) && moveType != :NORMAL
mults[FINAL_DMG_MULT] /= 2
target.damageState.berryWeakened = true
target.battle.pbCommonAnimation("EatBerry",target)

View File

@@ -519,7 +519,7 @@ BattleHandlers::AbilityOnStatLoss.add(:DEFIANT,
BattleHandlers::PriorityChangeAbility.add(:GALEWINGS,
proc { |ability,battler,move,pri|
next pri+1 if battler.hp==battler.totalhp && isConst?(move.type,PBTypes,:FLYING)
next pri+1 if battler.hp==battler.totalhp && move.type == :FLYING
}
)
@@ -605,7 +605,7 @@ BattleHandlers::MoveImmunityTargetAbility.add(:BULLETPROOF,
BattleHandlers::MoveImmunityTargetAbility.add(:FLASHFIRE,
proc { |ability,user,target,move,type,battle|
next false if user.index==target.index
next false if !isConst?(type,PBTypes,:FIRE)
next false if type != :FIRE
battle.pbShowAbilitySplash(target)
if !target.effects[PBEffects::FlashFire]
target.effects[PBEffects::FlashFire] = true
@@ -700,7 +700,7 @@ BattleHandlers::MoveImmunityTargetAbility.copy(:WATERABSORB,:DRYSKIN)
BattleHandlers::MoveImmunityTargetAbility.add(:WONDERGUARD,
proc { |ability,user,target,move,type,battle|
next false if move.statusMove?
next false if type<0 || PBTypes.superEffective?(target.damageState.typeMod)
next false if !type || PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
battle.pbShowAbilitySplash(target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
@@ -718,47 +718,47 @@ BattleHandlers::MoveImmunityTargetAbility.add(:WONDERGUARD,
BattleHandlers::MoveBaseTypeModifierAbility.add(:AERILATE,
proc { |ability,user,move,type|
next if !isConst?(type,PBTypes,:NORMAL) || !hasConst?(PBTypes,:FLYING)
next if type != :NORMAL || !GameData::Type.exists?(:FLYING)
move.powerBoost = true
next getConst(PBTypes,:FLYING)
next :FLYING
}
)
BattleHandlers::MoveBaseTypeModifierAbility.add(:GALVANIZE,
proc { |ability,user,move,type|
next if !isConst?(type,PBTypes,:NORMAL) || !hasConst?(PBTypes,:ELECTRIC)
next if type != :NORMAL || !GameData::Type.exists?(:ELECTRIC)
move.powerBoost = true
next getConst(PBTypes,:ELECTRIC)
next :ELECTRIC
}
)
BattleHandlers::MoveBaseTypeModifierAbility.add(:LIQUIDVOICE,
proc { |ability,user,move,type|
next getConst(PBTypes,:WATER) if hasConst?(PBTypes,:WATER) && move.soundMove?
next :WATER if GameData::Type.exists?(:WATER) && move.soundMove?
}
)
BattleHandlers::MoveBaseTypeModifierAbility.add(:NORMALIZE,
proc { |ability,user,move,type|
next if !hasConst?(PBTypes,:NORMAL)
next if !GameData::Type.exists?(:NORMAL)
move.powerBoost = true if NEWEST_BATTLE_MECHANICS
next getConst(PBTypes,:NORMAL)
next :NORMAL
}
)
BattleHandlers::MoveBaseTypeModifierAbility.add(:PIXILATE,
proc { |ability,user,move,type|
next if !isConst?(type,PBTypes,:NORMAL) || !hasConst?(PBTypes,:FAIRY)
next if type != :NORMAL || !GameData::Type.exists?(:FAIRY)
move.powerBoost = true
next getConst(PBTypes,:FAIRY)
next :FAIRY
}
)
BattleHandlers::MoveBaseTypeModifierAbility.add(:REFRIGERATE,
proc { |ability,user,move,type|
next if !isConst?(type,PBTypes,:NORMAL) || !hasConst?(PBTypes,:ICE)
next if type != :NORMAL || !GameData::Type.exists?(:ICE)
move.powerBoost = true
next getConst(PBTypes,:ICE)
next :ICE
}
)
@@ -818,7 +818,7 @@ BattleHandlers::AccuracyCalcUserAllyAbility.add(:VICTORYSTAR,
BattleHandlers::AccuracyCalcTargetAbility.add(:LIGHTNINGROD,
proc { |ability,mods,user,target,move,type|
mods[BASE_ACC] = 0 if isConst?(type,PBTypes,:ELECTRIC)
mods[BASE_ACC] = 0 if type == :ELECTRIC
}
)
@@ -846,7 +846,7 @@ BattleHandlers::AccuracyCalcTargetAbility.add(:SNOWCLOAK,
BattleHandlers::AccuracyCalcTargetAbility.add(:STORMDRAIN,
proc { |ability,mods,user,target,move,type|
mods[BASE_ACC] = 0 if isConst?(type,PBTypes,:WATER)
mods[BASE_ACC] = 0 if type == :WATER
}
)
@@ -894,7 +894,7 @@ 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)
if user.hp<=user.totalhp/3 && type == :FIRE
mults[ATK_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)
if user.effects[PBEffects::FlashFire] && type == :FIRE
mults[ATK_MULT] *= 1.5
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)
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
mults[FINAL_DMG_MULT] *= 1.25
end
}
@@ -988,7 +988,7 @@ 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)
if user.hp<=user.totalhp/3 && type == :GRASS
mults[ATK_MULT] *= 1.5
end
}
@@ -1015,9 +1015,7 @@ BattleHandlers::DamageCalcUserAbility.add(:RIVALRY,
BattleHandlers::DamageCalcUserAbility.add(:SANDFORCE,
proc { |ability,user,target,move,mults,baseDmg,type|
if user.battle.pbWeather==PBWeather::Sandstorm &&
(isConst?(type,PBTypes,:ROCK) ||
isConst?(type,PBTypes,:GROUND) ||
isConst?(type,PBTypes,:STEEL))
[:ROCK, :GROUND, :STEEL].include?(type)
mults[BASE_DMG_MULT] *= 1.3
end
}
@@ -1060,7 +1058,7 @@ BattleHandlers::DamageCalcUserAbility.add(:STAKEOUT,
BattleHandlers::DamageCalcUserAbility.add(:STEELWORKER,
proc { |ability,user,target,move,mults,baseDmg,type|
mults[ATK_MULT] *= 1.5 if isConst?(type,PBTypes,:STEEL)
mults[ATK_MULT] *= 1.5 if type == :STEEL
}
)
@@ -1072,7 +1070,7 @@ BattleHandlers::DamageCalcUserAbility.add(:STRONGJAW,
BattleHandlers::DamageCalcUserAbility.add(:SWARM,
proc { |ability,user,target,move,mults,baseDmg,type|
if user.hp<=user.totalhp/3 && isConst?(type,PBTypes,:BUG)
if user.hp<=user.totalhp/3 && type == :BUG
mults[ATK_MULT] *= 1.5
end
}
@@ -1089,13 +1087,13 @@ BattleHandlers::DamageCalcUserAbility.add(:TECHNICIAN,
BattleHandlers::DamageCalcUserAbility.add(:TINTEDLENS,
proc { |ability,user,target,move,mults,baseDmg,type|
mults[FINAL_DMG_MULT] *= 2 if PBTypes.resistant?(target.damageState.typeMod)
mults[FINAL_DMG_MULT] *= 2 if PBTypeEffectiveness.resistant?(target.damageState.typeMod)
}
)
BattleHandlers::DamageCalcUserAbility.add(:TORRENT,
proc { |ability,user,target,move,mults,baseDmg,type|
if user.hp<=user.totalhp/3 && isConst?(type,PBTypes,:WATER)
if user.hp<=user.totalhp/3 && type == :WATER
mults[ATK_MULT] *= 1.5
end
}
@@ -1117,7 +1115,7 @@ BattleHandlers::DamageCalcUserAbility.add(:TOXICBOOST,
BattleHandlers::DamageCalcUserAbility.add(:WATERBUBBLE,
proc { |ability,user,target,move,mults,baseDmg,type|
mults[ATK_MULT] *= 2 if isConst?(type,PBTypes,:WATER)
mults[ATK_MULT] *= 2 if type == :WATER
}
)
@@ -1147,15 +1145,13 @@ 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] *= 1.25
end
mults[BASE_DMG_MULT] *= 1.25 if type == :FIRE
}
)
BattleHandlers::DamageCalcTargetAbility.add(:FILTER,
proc { |ability,user,target,move,mults,baseDmg,type|
if PBTypes.superEffective?(target.damageState.typeMod)
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
mults[FINAL_DMG_MULT] *= 0.75
end
}
@@ -1174,7 +1170,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] *= 2 if move.calcType == :FIRE
mults[FINAL_DMG_MULT] /= 2 if move.contactMove?
}
)
@@ -1195,7 +1191,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:GRASSPELT,
BattleHandlers::DamageCalcTargetAbility.add(:HEATPROOF,
proc { |ability,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] /= 2 if isConst?(type,PBTypes,:FIRE)
mults[BASE_DMG_MULT] /= 2 if type == :FIRE
}
)
@@ -1209,25 +1205,19 @@ 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] /= 2
end
mults[FINAL_DMG_MULT] /= 2 if target.hp==target.totalhp
}
)
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] /= 2
end
mults[BASE_DMG_MULT] /= 2 if type == :FIRE || type == :ICE
}
)
BattleHandlers::DamageCalcTargetAbility.add(:WATERBUBBLE,
proc { |ability,user,target,move,mults,baseDmg,type|
if isConst?(type,PBTypes,:FIRE)
mults[FINAL_DMG_MULT] /= 2
end
mults[FINAL_DMG_MULT] /= 2 if type == :FIRE
}
)
@@ -1237,7 +1227,7 @@ BattleHandlers::DamageCalcTargetAbility.add(:WATERBUBBLE,
BattleHandlers::DamageCalcTargetAbilityNonIgnorable.add(:PRISMARMOR,
proc { |ability,user,target,move,mults,baseDmg,type|
if PBTypes.superEffective?(target.damageState.typeMod)
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
mults[FINAL_DMG_MULT] *= 0.75
end
}
@@ -1523,7 +1513,7 @@ BattleHandlers::TargetAbilityOnHit.copy(:IRONBARBS,:ROUGHSKIN)
BattleHandlers::TargetAbilityOnHit.add(:JUSTIFIED,
proc { |ability,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:DARK)
next if move.calcType != :DARK
target.pbRaiseStatStageByAbility(PBStats::ATTACK,1,target)
}
)
@@ -1572,9 +1562,7 @@ BattleHandlers::TargetAbilityOnHit.add(:POISONPOINT,
BattleHandlers::TargetAbilityOnHit.add(:RATTLED,
proc { |ability,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:BUG) &&
!isConst?(move.calcType,PBTypes,:DARK) &&
!isConst?(move.calcType,PBTypes,:GHOST)
next if ![:BUG, :DARK, :GHOST].include?(move.calcType)
target.pbRaiseStatStageByAbility(PBStats::SPEED,1,target)
}
)
@@ -1605,7 +1593,7 @@ BattleHandlers::TargetAbilityOnHit.add(:STATIC,
BattleHandlers::TargetAbilityOnHit.add(:WATERCOMPACTION,
proc { |ability,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:WATER)
next if move.calcType != :WATER
target.pbRaiseStatStageByAbility(PBStats::DEFENSE,2,target)
}
)
@@ -1737,9 +1725,9 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:BERSERK,
BattleHandlers::TargetAbilityAfterMoveUse.add(:COLORCHANGE,
proc { |ability,target,user,move,switched,battle|
next if target.damageState.calcDamage==0 || target.damageState.substitute
next if move.calcType<0 || PBTypes.isPseudoType?(move.calcType)
next if !move.calcType || PBTypes.isPseudoType?(move.calcType)
next if target.pbHasType?(move.calcType) && !target.pbHasOtherType?(move.calcType)
typeName = PBTypes.getName(move.calcType)
typeName = GameData::Type.get(move.calcType).name
battle.pbShowAbilitySplash(target)
target.pbChangeTypes(move.calcType)
battle.pbDisplay(_INTL("{1}'s {2} made it the {3} type!",target.pbThis,
@@ -2092,9 +2080,9 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
proc { |ability,battler,battle|
next if !battler.pbOwnedByPlayer?
battlerTypes = battler.pbTypes(true)
type1 = (battlerTypes.length>0) ? battlerTypes[0] : nil
type2 = (battlerTypes.length>1) ? battlerTypes[1] : type1
type3 = (battlerTypes.length>2) ? battlerTypes[2] : type2
type1 = battlerTypes[0]
type2 = battlerTypes[1] || type1
type3 = battlerTypes[2] || type2
found = false
battle.eachOtherSideBattler(battler.index) do |b|
b.eachMove do |m|
@@ -2105,8 +2093,8 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
moveType = pbHiddenPower(b.pokemon)[0]
end
eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3)
next if PBTypes.ineffective?(eff)
next if !PBTypes.superEffective?(eff) && m.function != "070" # OHKO
next if PBTypeEffectiveness.ineffective?(eff)
next if !PBTypeEffectiveness.superEffective?(eff) && m.function != "070" # OHKO
else
next if m.function != "070" # OHKO
end

View File

@@ -446,8 +446,7 @@ BattleHandlers::AccuracyCalcTargetItem.copy(:BRIGHTPOWDER,:LAXINCENSE)
BattleHandlers::DamageCalcUserItem.add(:ADAMANTORB,
proc { |item,user,target,move,mults,baseDmg,type|
if user.isSpecies?(:DIALGA) &&
(isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:STEEL))
if user.isSpecies?(:DIALGA) && (type == :DRAGON || type == :STEEL)
mults[BASE_DMG_MULT] *= 1.2
end
}
@@ -455,7 +454,7 @@ BattleHandlers::DamageCalcUserItem.add(:ADAMANTORB,
BattleHandlers::DamageCalcUserItem.add(:BLACKBELT,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FIGHTING)
mults[BASE_DMG_MULT] *= 1.2 if type == :FIGHTING
}
)
@@ -463,7 +462,7 @@ BattleHandlers::DamageCalcUserItem.copy(:BLACKBELT,:FISTPLATE)
BattleHandlers::DamageCalcUserItem.add(:BLACKGLASSES,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:DARK)
mults[BASE_DMG_MULT] *= 1.2 if type == :DARK
}
)
@@ -477,7 +476,7 @@ BattleHandlers::DamageCalcUserItem.add(:BUGGEM,
BattleHandlers::DamageCalcUserItem.add(:CHARCOAL,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FIRE)
mults[BASE_DMG_MULT] *= 1.2 if type == :FIRE
}
)
@@ -511,7 +510,7 @@ BattleHandlers::DamageCalcUserItem.add(:DEEPSEATOOTH,
BattleHandlers::DamageCalcUserItem.add(:DRAGONFANG,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:DRAGON)
mults[BASE_DMG_MULT] *= 1.2 if type == :DRAGON
}
)
@@ -531,7 +530,7 @@ BattleHandlers::DamageCalcUserItem.add(:ELECTRICGEM,
BattleHandlers::DamageCalcUserItem.add(:EXPERTBELT,
proc { |item,user,target,move,mults,baseDmg,type|
if PBTypes.superEffective?(target.damageState.typeMod)
if PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
mults[FINAL_DMG_MULT] *= 1.2
end
}
@@ -575,8 +574,7 @@ BattleHandlers::DamageCalcUserItem.add(:GRASSGEM,
BattleHandlers::DamageCalcUserItem.add(:GRISEOUSORB,
proc { |item,user,target,move,mults,baseDmg,type|
if user.isSpecies?(:GIRATINA) &&
(isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:GHOST))
if user.isSpecies?(:GIRATINA) && (type == :DRAGON || type == :GHOST)
mults[BASE_DMG_MULT] *= 1.2
end
}
@@ -590,7 +588,7 @@ BattleHandlers::DamageCalcUserItem.add(:GROUNDGEM,
BattleHandlers::DamageCalcUserItem.add(:HARDSTONE,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:ROCK)
mults[BASE_DMG_MULT] *= 1.2 if type == :ROCK
}
)
@@ -620,8 +618,7 @@ BattleHandlers::DamageCalcUserItem.add(:LIGHTBALL,
BattleHandlers::DamageCalcUserItem.add(:LUSTROUSORB,
proc { |item,user,target,move,mults,baseDmg,type|
if user.isSpecies?(:PALKIA) &&
(isConst?(type,PBTypes,:DRAGON) || isConst?(type,PBTypes,:WATER))
if user.isSpecies?(:PALKIA) && (type == :DRAGON || type == :WATER)
mults[BASE_DMG_MULT] *= 1.2
end
}
@@ -629,7 +626,7 @@ BattleHandlers::DamageCalcUserItem.add(:LUSTROUSORB,
BattleHandlers::DamageCalcUserItem.add(:MAGNET,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:ELECTRIC)
mults[BASE_DMG_MULT] *= 1.2 if type == :ELECTRIC
}
)
@@ -637,7 +634,7 @@ BattleHandlers::DamageCalcUserItem.copy(:MAGNET,:ZAPPLATE)
BattleHandlers::DamageCalcUserItem.add(:METALCOAT,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:STEEL)
mults[BASE_DMG_MULT] *= 1.2 if type == :STEEL
}
)
@@ -652,7 +649,7 @@ BattleHandlers::DamageCalcUserItem.add(:METRONOME,
BattleHandlers::DamageCalcUserItem.add(:MIRACLESEED,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:GRASS)
mults[BASE_DMG_MULT] *= 1.2 if type == :GRASS
}
)
@@ -666,7 +663,7 @@ BattleHandlers::DamageCalcUserItem.add(:MUSCLEBAND,
BattleHandlers::DamageCalcUserItem.add(:MYSTICWATER,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:WATER)
mults[BASE_DMG_MULT] *= 1.2 if type == :WATER
}
)
@@ -674,7 +671,7 @@ BattleHandlers::DamageCalcUserItem.copy(:MYSTICWATER,:SPLASHPLATE,:SEAINCENSE,:W
BattleHandlers::DamageCalcUserItem.add(:NEVERMELTICE,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:ICE)
mults[BASE_DMG_MULT] *= 1.2 if type == :ICE
}
)
@@ -688,13 +685,13 @@ BattleHandlers::DamageCalcUserItem.add(:NORMALGEM,
BattleHandlers::DamageCalcUserItem.add(:PIXIEPLATE,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FAIRY)
mults[BASE_DMG_MULT] *= 1.2 if type == :FAIRY
}
)
BattleHandlers::DamageCalcUserItem.add(:POISONBARB,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:POISON)
mults[BASE_DMG_MULT] *= 1.2 if type == :POISON
}
)
@@ -720,7 +717,7 @@ BattleHandlers::DamageCalcUserItem.add(:ROCKGEM,
BattleHandlers::DamageCalcUserItem.add(:SHARPBEAK,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:FLYING)
mults[BASE_DMG_MULT] *= 1.2 if type == :FLYING
}
)
@@ -728,13 +725,13 @@ BattleHandlers::DamageCalcUserItem.copy(:SHARPBEAK,:SKYPLATE)
BattleHandlers::DamageCalcUserItem.add(:SILKSCARF,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:NORMAL)
mults[BASE_DMG_MULT] *= 1.2 if type == :NORMAL
}
)
BattleHandlers::DamageCalcUserItem.add(:SILVERPOWDER,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:BUG)
mults[BASE_DMG_MULT] *= 1.2 if type == :BUG
}
)
@@ -742,7 +739,7 @@ BattleHandlers::DamageCalcUserItem.copy(:SILVERPOWDER,:INSECTPLATE)
BattleHandlers::DamageCalcUserItem.add(:SOFTSAND,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:GROUND)
mults[BASE_DMG_MULT] *= 1.2 if type == :GROUND
}
)
@@ -752,9 +749,7 @@ BattleHandlers::DamageCalcUserItem.add(:SOULDEW,
proc { |item,user,target,move,mults,baseDmg,type|
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] *= 1.2
end
mults[FINAL_DMG_MULT] *= 1.2 if type == :PSYCHIC || type == :DRAGON
else
if move.specialMove? && !user.battle.rules["souldewclause"]
mults[ATK_MULT] *= 1.5
@@ -765,7 +760,7 @@ BattleHandlers::DamageCalcUserItem.add(:SOULDEW,
BattleHandlers::DamageCalcUserItem.add(:SPELLTAG,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:GHOST)
mults[BASE_DMG_MULT] *= 1.2 if type == :GHOST
}
)
@@ -787,7 +782,7 @@ BattleHandlers::DamageCalcUserItem.add(:THICKCLUB,
BattleHandlers::DamageCalcUserItem.add(:TWISTEDSPOON,
proc { |item,user,target,move,mults,baseDmg,type|
mults[BASE_DMG_MULT] *= 1.2 if isConst?(type,PBTypes,:PSYCHIC)
mults[BASE_DMG_MULT] *= 1.2 if type == :PSYCHIC
}
)
@@ -999,7 +994,7 @@ BattleHandlers::CriticalCalcUserItem.add(:STICK,
BattleHandlers::TargetItemOnHit.add(:ABSORBBULB,
proc { |item,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:WATER)
next if move.calcType != :WATER
next if !target.pbCanRaiseStatStage?(PBStats::SPATK,target)
battle.pbCommonAnimation("UseItem",target)
target.pbRaiseStatStageByCause(PBStats::SPATK,1,target,target.itemName)
@@ -1017,7 +1012,7 @@ BattleHandlers::TargetItemOnHit.add(:AIRBALLOON,
BattleHandlers::TargetItemOnHit.add(:CELLBATTERY,
proc { |item,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:ELECTRIC)
next if move.calcType != :ELECTRIC
next if !target.pbCanRaiseStatStage?(PBStats::ATTACK,target)
battle.pbCommonAnimation("UseItem",target)
target.pbRaiseStatStageByCause(PBStats::ATTACK,1,target,target.itemName)
@@ -1028,7 +1023,7 @@ BattleHandlers::TargetItemOnHit.add(:CELLBATTERY,
BattleHandlers::TargetItemOnHit.add(:ENIGMABERRY,
proc { |item,user,target,move,battle|
next if target.damageState.substitute || target.damageState.disguise
next if !PBTypes.superEffective?(target.damageState.typeMod)
next if !PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(item,target,battle,false)
target.pbHeldItemTriggered(item)
end
@@ -1065,7 +1060,7 @@ BattleHandlers::TargetItemOnHit.add(:KEEBERRY,
BattleHandlers::TargetItemOnHit.add(:LUMINOUSMOSS,
proc { |item,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:WATER)
next if move.calcType != :WATER
next if !target.pbCanRaiseStatStage?(PBStats::SPDEF,target)
battle.pbCommonAnimation("UseItem",target)
target.pbRaiseStatStageByCause(PBStats::SPDEF,1,target,target.itemName)
@@ -1113,7 +1108,7 @@ BattleHandlers::TargetItemOnHit.add(:ROWAPBERRY,
BattleHandlers::TargetItemOnHit.add(:SNOWBALL,
proc { |item,user,target,move,battle|
next if !isConst?(move.calcType,PBTypes,:ICE)
next if move.calcType != :ICE
next if !target.pbCanRaiseStatStage?(PBStats::ATTACK,target)
battle.pbCommonAnimation("UseItem",target)
target.pbRaiseStatStageByCause(PBStats::ATTACK,1,target,target.itemName)
@@ -1142,7 +1137,7 @@ BattleHandlers::TargetItemOnHit.add(:STICKYBARB,
BattleHandlers::TargetItemOnHit.add(:WEAKNESSPOLICY,
proc { |item,user,target,move,battle|
next if target.damageState.disguise
next if !PBTypes.superEffective?(target.damageState.typeMod)
next if !PBTypeEffectiveness.superEffective?(target.damageState.typeMod)
next if !target.pbCanRaiseStatStage?(PBStats::ATTACK,target) &&
!target.pbCanRaiseStatStage?(PBStats::SPATK,target)
battle.pbCommonAnimation("UseItem",target)

View File

@@ -24,7 +24,7 @@ class PokeBattle_DamageState
def reset
@initialHP = 0
@typeMod = 0
@typeMod = PBTypeEffectiveness::INEFFECTIVE
@unaffected = false
@protected = false
@magicCoat = false
@@ -73,10 +73,10 @@ class PokeBattle_SuccessState
if @useState==1
@skill = -2 if !@protected
elsif @useState==2
if PBTypes.superEffective?(@typeMod); @skill = 2
elsif PBTypes.normalEffective?(@typeMod); @skill = 1
elsif PBTypes.notVeryEffective?(@typeMod); @skill = -1
else; @skill = -2 # Ineffective
if PBTypeEffectiveness.superEffective?(@typeMod); @skill = 2
elsif PBTypeEffectiveness.normalEffective?(@typeMod); @skill = 1
elsif PBTypeEffectiveness.notVeryEffective?(@typeMod); @skill = -1
else; @skill = -2 # Ineffective
end
end
clear(false)