Merged species Type1/Type2 into Types, did the same for Pokemon and Battler

This commit is contained in:
Maruno17
2021-11-22 23:55:28 +00:00
parent a5f91f62ea
commit 00c2df5772
33 changed files with 3756 additions and 5552 deletions

View File

@@ -6,8 +6,7 @@ class Battle::Battler
attr_reader :pokemon
attr_accessor :pokemonIndex
attr_accessor :species
attr_accessor :type1
attr_accessor :type2
attr_accessor :types
attr_accessor :ability_id
attr_accessor :item_id
attr_accessor :moves
@@ -304,8 +303,7 @@ class Battle::Battler
# same type more than once, and should not include any invalid type numbers
# (e.g. -1).
def pbTypes(withType3=false)
ret = [@type1]
ret.push(@type2) if @type2!=@type1
ret = @types.clone
# Burn Up erases the Fire-type.
ret.delete(:FIRE) if @effects[PBEffects::BurnUp]
# Roost erases the Flying-type. If there are no types left, adds the Normal-

View File

@@ -20,7 +20,7 @@ class Battle::Battler
@form = 0
@level = 0
@hp = @totalhp = 0
@type1 = @type2 = nil
@types = []
@ability_id = nil
@item_id = nil
@gender = 0
@@ -44,8 +44,7 @@ class Battle::Battler
@level = pkmn.level
@hp = pkmn.hp
@totalhp = pkmn.totalhp
@type1 = pkmn.type1
@type2 = pkmn.type2
@types = pkmn.types
# ability and item intentionally not copied across here
@gender = pkmn.gender
@attack = pkmn.attack
@@ -78,8 +77,7 @@ class Battle::Battler
@level = pkmn.level
@hp = pkmn.hp
@totalhp = pkmn.totalhp
@type1 = pkmn.type1
@type2 = pkmn.type2
@types = pkmn.types
@ability_id = pkmn.ability_id
@item_id = pkmn.item_id
@gender = pkmn.gender
@@ -312,8 +310,7 @@ class Battle::Battler
@spdef = @pokemon.spdef
@speed = @pokemon.speed
if fullChange
@type1 = @pokemon.type1
@type2 = @pokemon.type2
@types = @pokemon.types
@ability_id = @pokemon.ability_id
end
end

View File

@@ -127,13 +127,11 @@ class Battle::Battler
newTypes.push(:NORMAL) if newTypes.length == 0
newType3 = newType.effects[PBEffects::Type3]
newType3 = nil if newTypes.include?(newType3)
@type1 = newTypes[0]
@type2 = (newTypes.length == 1) ? newTypes[0] : newTypes[1]
@types = newTypes.clone
@effects[PBEffects::Type3] = newType3
else
newType = GameData::Type.get(newType).id
@type1 = newType
@type2 = newType
@types = [newType]
@effects[PBEffects::Type3] = nil
end
@effects[PBEffects::BurnUp] = false
@@ -141,8 +139,7 @@ class Battle::Battler
end
def pbResetTypes
@type1 = @pokemon.type1
@type2 = @pokemon.type2
@types = @pokemon.types
@effects[PBEffects::Type3] = nil
@effects[PBEffects::BurnUp] = false
@effects[PBEffects::Roost] = false

View File

@@ -2458,8 +2458,8 @@ class Battle::AI
when "UseTargetDefenseInsteadOfTargetSpDef"
#---------------------------------------------------------------------------
when "FailsUnlessTargetSharesTypeWithUser"
if !target.pbHasType?(user.type1) &&
!target.pbHasType?(user.type2)
if !(user.types[0] && target.pbHasType?(user.types[0])) &&
!(user.types[1] && target.pbHasType?(user.types[1]))
score -= 90
end
#---------------------------------------------------------------------------

View File

@@ -82,10 +82,10 @@ class Battle::AI
# For switching. Determines the effectiveness of a potential switch-in against
# an opposing battler.
def pbCalcTypeModPokemon(battlerThis,_battlerOther)
mod1 = Effectiveness.calculate(battlerThis.type1,target.type1,target.type2)
mod1 = Effectiveness.calculate(battlerThis.types[0], target.types[0], target.types[1])
mod2 = Effectiveness::NORMAL_EFFECTIVE
if battlerThis.type1!=battlerThis.type2
mod2 = Effectiveness.calculate(battlerThis.type2,target.type1,target.type2)
if battlerThis.types.length > 1
mod2 = Effectiveness.calculate(battlerThis.types[1], target.types[0], target.types[1])
mod2 = mod2.to_f / Effectivenesss::NORMAL_EFFECTIVE
end
return mod1*mod2
@@ -275,7 +275,7 @@ class Battle::AI
baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round
else
mult = Effectiveness.calculate(:FLYING,
target.type1,target.type2,target.effects[PBEffects::Type3])
target.types[0], target.types[1], target.effects[PBEffects::Type3])
baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round
end
end

View File

@@ -2590,19 +2590,17 @@ Battle::AbilityEffects::OnSwitchIn.add(:ANTICIPATION,
proc { |ability,battler,battle|
next if !battler.pbOwnedByPlayer?
battlerTypes = battler.pbTypes(true)
type1 = battlerTypes[0]
type2 = battlerTypes[1] || type1
type3 = battlerTypes[2] || type2
types = battlerTypes
found = false
battle.allOtherSideBattlers(battler.index).each do |b|
b.eachMove do |m|
next if m.statusMove?
if type1
if types.length > 0
moveType = m.type
if Settings::MECHANICS_GENERATION >= 6 && m.function == "TypeDependsOnUserIVs" # Hidden Power
moveType = pbHiddenPower(b.pokemon)[0]
end
eff = Effectiveness.calculate(moveType,type1,type2,type3)
eff = Effectiveness.calculate(moveType, types[0], types[1], types[2])
next if Effectiveness.ineffective?(eff)
next if !Effectiveness.super_effective?(eff) &&
!["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)