Moved move data constants into module MoveData

This commit is contained in:
Maruno17
2020-10-17 00:29:58 +01:00
parent d3ec5c2c53
commit c30e302ccf
15 changed files with 131 additions and 129 deletions

View File

@@ -583,7 +583,7 @@ class PokeBattle_Battler
def inTwoTurnAttack?(*arg)
return false if @effects[PBEffects::TwoTurnAttack]==0
ttaFunction = pbGetMoveData(@effects[PBEffects::TwoTurnAttack],MOVE_FUNCTION_CODE)
ttaFunction = pbGetMoveData(@effects[PBEffects::TwoTurnAttack],MoveData::FUNCTION_CODE)
arg.each { |a| return true if a==ttaFunction }
return false
end

View File

@@ -30,16 +30,16 @@ class PokeBattle_Move
@name = PBMoves.getName(@id) # Get the move's name
# Get data on the move
moveData = pbGetMoveData(@id)
@function = moveData[MOVE_FUNCTION_CODE]
@baseDamage = moveData[MOVE_BASE_DAMAGE]
@type = moveData[MOVE_TYPE]
@category = moveData[MOVE_CATEGORY]
@accuracy = moveData[MOVE_ACCURACY]
@function = moveData[MoveData::FUNCTION_CODE]
@baseDamage = moveData[MoveData::BASE_DAMAGE]
@type = moveData[MoveData::TYPE]
@category = moveData[MoveData::CATEGORY]
@accuracy = moveData[MoveData::ACCURACY]
@pp = move.pp # Can be changed with Mimic/Transform
@addlEffect = moveData[MOVE_EFFECT_CHANCE]
@target = moveData[MOVE_TARGET]
@priority = moveData[MOVE_PRIORITY]
@flags = moveData[MOVE_FLAGS]
@addlEffect = moveData[MoveData::EFFECT_CHANCE]
@target = moveData[MoveData::TARGET]
@priority = moveData[MoveData::PRIORITY]
@flags = moveData[MoveData::FLAGS]
@calcType = -1
@powerBoost = false # For Aerilate, Pixilate, Refrigerate, Galvanize
@snatched = false
@@ -50,7 +50,7 @@ class PokeBattle_Move
# function code (found in the script section PokeBattle_MoveEffect).
def PokeBattle_Move.pbFromPBMove(battle,move)
move = PBMove.new(0) if !move
moveFunction = pbGetMoveData(move.id,MOVE_FUNCTION_CODE) || "000"
moveFunction = pbGetMoveData(move.id,MoveData::FUNCTION_CODE) || "000"
className = sprintf("PokeBattle_Move_%s",moveFunction)
if Object.const_defined?(className)
return Object.const_get(className).new(battle,move)

View File

@@ -1708,8 +1708,8 @@ class PokeBattle_Move_05C < PokeBattle_Move
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed)
if target.lastRegularMoveUsed<=0 ||
user.pbHasMove?(target.lastRegularMoveUsed) ||
@moveBlacklist.include?(lastMoveData[MOVE_FUNCTION_CODE]) ||
isConst?(lastMoveData[MOVE_TYPE],PBTypes,:SHADOW)
@moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1759,8 +1759,8 @@ class PokeBattle_Move_05D < PokeBattle_Move
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed)
if target.lastRegularMoveUsed<=0 ||
user.pbHasMove?(target.lastRegularMoveUsed) ||
@moveBlacklist.include?(lastMoveData[MOVE_FUNCTION_CODE]) ||
isConst?(lastMoveData[MOVE_TYPE],PBTypes,:SHADOW)
@moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1837,7 +1837,7 @@ class PokeBattle_Move_05F < PokeBattle_Move
def pbFailsAgainstTarget?(user,target)
if target.lastMoveUsed<=0 ||
target.lastMoveUsedType<0 ||
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MOVE_TYPE))
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE))
@battle.pbDisplay(_INTL("But it failed!"))
return true
end

View File

@@ -1125,7 +1125,7 @@ class PokeBattle_Move_0AE < PokeBattle_Move
def pbFailsAgainstTarget?(user,target)
if target.lastRegularMoveUsed<=0 ||
!pbGetMoveData(target.lastRegularMoveUsed,MOVE_FLAGS)[/e/] # Not copyable by Mirror Move
!pbGetMoveData(target.lastRegularMoveUsed,MoveData::FLAGS)[/e/] # Not copyable by Mirror Move
@battle.pbDisplay(_INTL("The mirror move failed!"))
return true
end
@@ -1216,7 +1216,7 @@ class PokeBattle_Move_0AF < PokeBattle_Move
def pbMoveFailed?(user,targets)
if @battle.lastMoveUsed<=0 ||
@moveBlacklist.include?(pbGetMoveData(@battle.lastMoveUsed,MOVE_FUNCTION_CODE))
@moveBlacklist.include?(pbGetMoveData(@battle.lastMoveUsed,MoveData::FUNCTION_CODE))
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1560,7 +1560,7 @@ class PokeBattle_Move_0B5 < PokeBattle_Move
next if NEWEST_BATTLE_MECHANICS && pkmn.egg?
pkmn.moves.each do |move|
next if !move || move.id<=0
next if @moveBlacklist.include?(pbGetMoveData(move.id,MOVE_FUNCTION_CODE))
next if @moveBlacklist.include?(pbGetMoveData(move.id,MoveData::FUNCTION_CODE))
next if isConst?(move.type,PBTypes,:SHADOW)
@assistMoves.push(move.id)
end
@@ -1678,14 +1678,14 @@ class PokeBattle_Move_0B6 < PokeBattle_Move
1000.times do
move = @battle.pbRandom(PBMoves.maxValue)+1 # Random move
next if !movesData[move]
next if @moveBlacklist.include?(movesData[move][MOVE_FUNCTION_CODE])
next if @moveBlacklist.include?(movesData[move][MoveData::FUNCTION_CODE])
blMove = false
@moveBlacklistSignatures.each do |m|
next if !isConst?(move,PBMoves,m)
blMove = true; break
end
next if blMove
next if isConst?(movesData[move][MOVE_TYPE],PBTypes,:SHADOW)
next if isConst?(movesData[move][MoveData::TYPE],PBTypes,:SHADOW)
@metronomeMove = move
break
end
@@ -1881,7 +1881,7 @@ class PokeBattle_Move_0BC < PokeBattle_Move
return true
end
if target.lastRegularMoveUsed<=0 ||
@moveBlacklist.include?(pbGetMoveData(target.lastRegularMoveUsed,MOVE_FUNCTION_CODE))
@moveBlacklist.include?(pbGetMoveData(target.lastRegularMoveUsed,MoveData::FUNCTION_CODE))
@battle.pbDisplay(_INTL("But it failed!"))
return true
end

View File

@@ -2342,7 +2342,7 @@ class PokeBattle_Move_16B < PokeBattle_Move
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
if @moveBlacklist.include?(pbGetMoveData(target.lastRegularMoveUsed,MOVE_FUNCTION_CODE))
if @moveBlacklist.include?(pbGetMoveData(target.lastRegularMoveUsed,MoveData::FUNCTION_CODE))
@battle.pbDisplay(_INTL("But it failed!"))
return true
end

View File

@@ -20,10 +20,10 @@ class PokeBattle_AI
if !target.fainted? && target.lastMoveUsed>0 &&
(target.level-battler.level).abs<=6
moveData = pbGetMoveData(target.lastMoveUsed)
moveType = moveData[MOVE_TYPE]
moveType = moveData[MoveData::TYPE]
typeMod = pbCalcTypeMod(moveType,target,battler)
if PBTypes.superEffective?(typeMod) && moveData[MOVE_BASE_DAMAGE]>50
switchChance = (moveData[MOVE_BASE_DAMAGE]>70) ? 30 : 20
if PBTypes.superEffective?(typeMod) && moveData[MoveData::BASE_DAMAGE]>50
switchChance = (moveData[MoveData::BASE_DAMAGE]>70) ? 30 : 20
shouldSwitch = (pbAIRandom(100)<switchChance)
end
end
@@ -165,10 +165,10 @@ class PokeBattle_AI
pkmn.moves.each do |m|
next if m.id==0
moveData = movesData[m.id]
next if moveData[MOVE_BASE_DAMAGE]==0
next if moveData[MoveData::BASE_DAMAGE]==0
@battle.battlers[idxBattler].eachOpposing do |b|
bTypes = b.pbTypes(true)
sum += PBTypes.getCombinedEffectiveness(moveData[MOVE_TYPE],
sum += PBTypes.getCombinedEffectiveness(moveData[MoveData::TYPE],
bTypes[0],bTypes[1],bTypes[2])
end
end

View File

@@ -1278,8 +1278,8 @@ class PokeBattle_AI
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed)
if user.effects[PBEffects::Transform] ||
target.lastRegularMoveUsed<=0 ||
moveBlacklist.include?(lastMoveData[MOVE_FUNCTION_CODE]) ||
isConst?(lastMoveData[MOVE_TYPE],PBTypes,:SHADOW)
moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW)
score -= 90
end
user.eachMove do |m|
@@ -1297,8 +1297,8 @@ class PokeBattle_AI
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed)
if user.effects[PBEffects::Transform] ||
target.lastRegularMoveUsed<=0 ||
moveBlacklist.include?(lastMoveData[MOVE_FUNCTION_CODE]) ||
isConst?(lastMoveData[MOVE_TYPE],PBTypes,:SHADOW)
moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW)
score -= 90
end
user.eachMove do |m|
@@ -1327,7 +1327,7 @@ class PokeBattle_AI
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
score -= 90
elsif target.lastMoveUsed<=0 ||
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MOVE_TYPE))
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE))
score -= 90
else
aType = -1
@@ -1551,9 +1551,9 @@ class PokeBattle_AI
score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed>0
moveData = pbGetMoveData(target.lastMoveUsed)
if moveData[MOVE_BASE_DAMAGE]>0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MOVE_CATEGORY]==0) ||
(!MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData[MOVE_TYPE]))
if moveData[MoveData::BASE_DAMAGE]>0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MoveData::CATEGORY]==0) ||
(!MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData[MoveData::TYPE]))
score -= 60
end
end
@@ -1569,9 +1569,9 @@ class PokeBattle_AI
score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed>0
moveData = pbGetMoveData(target.lastMoveUsed)
if moveData[MOVE_BASE_DAMAGE]>0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MOVE_CATEGORY]==1) ||
(!MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData[MOVE_TYPE]))
if moveData[MoveData::BASE_DAMAGE]>0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MoveData::CATEGORY]==1) ||
(!MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData[MoveData::TYPE]))
score -= 60
end
end
@@ -1764,7 +1764,7 @@ class PokeBattle_AI
score -= 40
if skill>=PBTrainerAI.highSkill
score -= 100 if target.lastRegularMoveUsed<=0 ||
!pbGetMoveData(target.lastRegularMoveUsed,MOVE_FLAGS)[/e/] # Not copyable by Mirror Move
!pbGetMoveData(target.lastRegularMoveUsed,MoveData::FLAGS)[/e/] # Not copyable by Mirror Move
end
#---------------------------------------------------------------------------
when "0AF"
@@ -1813,13 +1813,13 @@ class PokeBattle_AI
score -= 90
else
moveData = pbGetMoveData(target.lastRegularMoveUsed)
if moveData[MOVE_CATEGORY]==2 && # Status move
(moveData[MOVE_TARGET]==PBTargets::User ||
moveData[MOVE_TARGET]==PBTargets::BothSides)
if moveData[MoveData::CATEGORY]==2 && # Status move
(moveData[MoveData::TARGET]==PBTargets::User ||
moveData[MoveData::TARGET]==PBTargets::BothSides)
score += 60
elsif moveData[MOVE_CATEGORY]!=2 && # Damaging move
moveData[MOVE_TARGET]==PBTargets::NearOther &&
PBTypes.ineffective?(pbCalcTypeMod(moveData[MOVE_TYPE],target,user))
elsif moveData[MoveData::CATEGORY]!=2 && # Damaging move
moveData[MoveData::TARGET]==PBTargets::NearOther &&
PBTypes.ineffective?(pbCalcTypeMod(moveData[MoveData::TYPE],target,user))
score += 60
end
end
@@ -2096,7 +2096,7 @@ class PokeBattle_AI
:CHOICEBAND,:CHOICESCARF,:CHOICESPECS])
score += 50
elsif user.item==0 && target.item!=0
score -= 30 if pbGetMoveData(user.lastMoveUsed,MOVE_FUNCTION_CODE)=="0F2" # Trick/Switcheroo
score -= 30 if pbGetMoveData(user.lastMoveUsed,MoveData::FUNCTION_CODE)=="0F2" # Trick/Switcheroo
end
#---------------------------------------------------------------------------
when "0F3"

View File

@@ -408,12 +408,12 @@ class PokeBattle_Scene
return anim if anim
# Actual animation not found, get the default animation for the move's type
moveData = pbGetMoveData(moveID)
moveType = moveData[MOVE_TYPE]
moveKind = moveData[MOVE_CATEGORY]
moveKind += 3 if PBTargets.multipleTargets?(moveData[MOVE_TARGET]) ||
PBTargets.targetsFoeSide?(moveData[MOVE_TARGET])
moveKind += 3 if moveKind==2 && moveData[MOVE_TARGET]!=PBTargets::User &&
moveData[MOVE_TARGET]!=PBTargets::UserSide
moveType = moveData[MoveData::TYPE]
moveKind = moveData[MoveData::CATEGORY]
moveKind += 3 if PBTargets.multipleTargets?(moveData[MoveData::TARGET]) ||
PBTargets.targetsFoeSide?(moveData[MoveData::TARGET])
moveKind += 3 if moveKind==2 && moveData[MoveData::TARGET]!=PBTargets::User &&
moveData[MoveData::TARGET]!=PBTargets::UserSide
# [one target physical, one target special, user status,
# multiple targets physical, multiple targets special, non-user status]
typeDefaultAnim = {

View File

@@ -2099,15 +2099,15 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
next if m.statusMove?
moveData = pbGetMoveData(m.id)
if type1
moveType = moveData[MOVE_TYPE]
moveType = moveData[MoveData::TYPE]
if NEWEST_BATTLE_MECHANICS && isConst?(m.id,PBMoves,:HIDDENPOWER)
moveType = pbHiddenPower(b.pokemon)[0]
end
eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3)
next if PBTypes.ineffective?(eff)
next if !PBTypes.superEffective?(eff) && moveData[MOVE_FUNCTION_CODE]!="070" # OHKO
next if !PBTypes.superEffective?(eff) && moveData[MoveData::FUNCTION_CODE]!="070" # OHKO
else
next if moveData[MOVE_FUNCTION_CODE]!="070" # OHKO
next if moveData[MoveData::FUNCTION_CODE]!="070" # OHKO
end
found = true
break
@@ -2207,17 +2207,17 @@ BattleHandlers::AbilityOnSwitchIn.add(:FOREWARN,
battle.eachOtherSideBattler(battler.index) do |b|
b.eachMove do |m|
moveData = pbGetMoveData(m.id)
power = moveData[MOVE_BASE_DAMAGE]
power = 160 if ["070"].include?(moveData[MOVE_FUNCTION_CODE]) # OHKO
power = 150 if ["08B"].include?(moveData[MOVE_FUNCTION_CODE]) # Eruption
power = moveData[MoveData::BASE_DAMAGE]
power = 160 if ["070"].include?(moveData[MoveData::FUNCTION_CODE]) # OHKO
power = 150 if ["08B"].include?(moveData[MoveData::FUNCTION_CODE]) # Eruption
# Counter, Mirror Coat, Metal Burst
power = 120 if ["071","072","073"].include?(moveData[MOVE_FUNCTION_CODE])
power = 120 if ["071","072","073"].include?(moveData[MoveData::FUNCTION_CODE])
# Sonic Boom, Dragon Rage, Night Shade, Endeavor, Psywave,
# Return, Frustration, Crush Grip, Gyro Ball, Hidden Power,
# Natural Gift, Trump Card, Flail, Grass Knot
power = 80 if ["06A","06B","06D","06E","06F",
"089","08A","08C","08D","090",
"096","097","098","09A"].include?(moveData[MOVE_FUNCTION_CODE])
"096","097","098","09A"].include?(moveData[MoveData::FUNCTION_CODE])
next if power<highestPower
forewarnMoves = [] if power>highestPower
forewarnMoves.push(m.id)