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