Implemented GameData::Move

This commit is contained in:
Maruno17
2020-11-19 21:00:29 +00:00
parent 52ffae9e8a
commit 3cd8d59918
71 changed files with 1443 additions and 1584 deletions

View File

@@ -17,14 +17,14 @@ class PokeBattle_AI
# super-effective and powerful
if !shouldSwitch && battler.turnCount>0 && skill>=PBTrainerAI.highSkill
target = battler.pbDirectOpposing(true)
if !target.fainted? && target.lastMoveUsed>0 &&
if !target.fainted? && target.lastMoveUsed &&
(target.level-battler.level).abs<=6
moveData = pbGetMoveData(target.lastMoveUsed)
moveType = moveData[MoveData::TYPE]
moveData = GameData::Move.get(target.lastMoveUsed)
moveType = moveData.type
typeMod = pbCalcTypeMod(moveType,target,battler)
if PBTypes.superEffective?(typeMod) && moveData[MoveData::BASE_DAMAGE]>50
switchChance = (moveData[MoveData::BASE_DAMAGE]>70) ? 30 : 20
shouldSwitch = (pbAIRandom(100)<switchChance)
if PBTypes.superEffective?(typeMod) && moveData.base_damage > 50
switchChance = (moveData.base_damage > 70) ? 30 : 20
shouldSwitch = (pbAIRandom(100) < switchChance)
end
end
end
@@ -158,18 +158,14 @@ class PokeBattle_AI
return -1 if !enemies || enemies.length==0
best = -1
bestSum = 0
movesData = pbLoadMovesData
enemies.each do |i|
pkmn = party[i]
sum = 0
pkmn.moves.each do |m|
next if m.id==0
moveData = movesData[m.id]
next if moveData[MoveData::BASE_DAMAGE]==0
next if m.base_damage == 0
@battle.battlers[idxBattler].eachOpposing do |b|
bTypes = b.pbTypes(true)
sum += PBTypes.getCombinedEffectiveness(moveData[MoveData::TYPE],
bTypes[0],bTypes[1],bTypes[2])
sum += PBTypes.getCombinedEffectiveness(m.type, bTypes[0], bTypes[1], bTypes[2])
end
end
if best==-1 || sum>bestSum

View File

@@ -105,7 +105,7 @@ class PokeBattle_AI
end
# Log the result
if @battle.choices[idxBattler][2]
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use #{@battle.choices[user.index][2].name}")
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use #{@battle.choices[idxBattler][2].name}")
end
end

View File

@@ -70,7 +70,7 @@ class PokeBattle_AI
when "007", "008", "009", "0C5"
if target.pbCanParalyze?(user,false) &&
!(skill>=PBTrainerAI.mediumSkill &&
isConst?(move.id,PBMoves,:THUNDERWAVE) &&
move.id == :THUNDERWAVE &&
PBTypes.ineffective?(pbCalcTypeMod(move.type,user,target)))
score += 30
if skill>=PBTrainerAI.mediumSkill
@@ -1275,17 +1275,19 @@ class PokeBattle_AI
"05D", # Sketch
"0B6" # Metronome
]
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed)
if user.effects[PBEffects::Transform] ||
target.lastRegularMoveUsed<=0 ||
moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW)
if user.effects[PBEffects::Transform] || !target.lastRegularMoveUsed
score -= 90
end
user.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed
score -= 90
break
else
lastMoveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
score -= 90
end
user.eachMove do |m|
next if m != target.lastRegularMoveUsed
score -= 90
break
end
end
#---------------------------------------------------------------------------
when "05D"
@@ -1294,17 +1296,19 @@ class PokeBattle_AI
"014", # Chatter
"05D" # Sketch
]
lastMoveData = pbGetMoveData(target.lastRegularMoveUsed)
if user.effects[PBEffects::Transform] ||
target.lastRegularMoveUsed<=0 ||
moveBlacklist.include?(lastMoveData[MoveData::FUNCTION_CODE]) ||
isConst?(lastMoveData[MoveData::TYPE],PBTypes,:SHADOW)
if user.effects[PBEffects::Transform] || !target.lastRegularMoveUsed
score -= 90
end
user.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed
score -= 90 # User already knows the move that will be Sketched
break
else
lastMoveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveBlacklist.include?(lastMoveData.function_code) ||
isConst?(lastMoveData.type, PBTypes,:SHADOW)
score -= 90
end
user.eachMove do |m|
next if m != target.lastRegularMoveUsed
score -= 90 # User already knows the move that will be Sketched
break
end
end
#---------------------------------------------------------------------------
when "05E"
@@ -1324,8 +1328,8 @@ class PokeBattle_AI
when "05F"
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
score -= 90
elsif target.lastMoveUsed<=0 ||
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE))
elsif !target.lastMoveUsed ||
PBTypes.isPseudoType?(GameData::Move.get(target.lastMoveUsed).type)
score -= 90
else
aType = -1
@@ -1507,11 +1511,11 @@ class PokeBattle_AI
spatk = pbRoughStat(user,PBStats::SPATK,skill)
if attack*1.5<spatk
score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed>0
moveData = pbGetMoveData(target.lastMoveUsed)
if moveData[MoveData::BASE_DAMAGE]>0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MoveData::CATEGORY]==0) ||
(!MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData[MoveData::TYPE]))
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed
moveData = GameData::Move.get(target.lastMoveUsed)
if moveData.base_damage > 0 &&
(MOVE_CATEGORY_PER_MOVE && moveData.category == 0) ||
(!MOVE_CATEGORY_PER_MOVE && PBTypes.isPhysicalType?(moveData.type))
score -= 60
end
end
@@ -1525,11 +1529,11 @@ class PokeBattle_AI
spatk = pbRoughStat(user,PBStats::SPATK,skill)
if attack>spatk*1.5
score -= 60
elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed>0
moveData = pbGetMoveData(target.lastMoveUsed)
if moveData[MoveData::BASE_DAMAGE]>0 &&
(MOVE_CATEGORY_PER_MOVE && moveData[MoveData::CATEGORY]==1) ||
(!MOVE_CATEGORY_PER_MOVE && !PBTypes.isSpecialType?(moveData[MoveData::TYPE]))
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 && !PBTypes.isSpecialType?(moveData.type))
score -= 60
end
end
@@ -1709,7 +1713,7 @@ class PokeBattle_AI
score -= user.effects[PBEffects::ProtectRate]*40
end
score += 50 if user.turnCount==0
score += 30 if target.effects[PBEffects::TwoTurnAttack]>0
score += 30 if target.effects[PBEffects::TwoTurnAttack]
end
#---------------------------------------------------------------------------
when "0AB"
@@ -1721,8 +1725,8 @@ class PokeBattle_AI
when "0AE"
score -= 40
if skill>=PBTrainerAI.highSkill
score -= 100 if target.lastRegularMoveUsed<=0 ||
!pbGetMoveData(target.lastRegularMoveUsed,MoveData::FLAGS)[/e/] # Not copyable by Mirror Move
score -= 100 if !target.lastRegularMoveUsed ||
!GameData::Move.get(target.lastRegularMoveUsed).flags[/e/] # Not copyable by Mirror Move
end
#---------------------------------------------------------------------------
when "0AF"
@@ -1767,17 +1771,16 @@ class PokeBattle_AI
if target.effects[PBEffects::Encore]>0
score -= 90
elsif aspeed>ospeed
if target.lastMoveUsed<=0
if !target.lastRegularMoveUsed
score -= 90
else
moveData = pbGetMoveData(target.lastRegularMoveUsed)
if moveData[MoveData::CATEGORY]==2 && # Status move
(moveData[MoveData::TARGET]==PBTargets::User ||
moveData[MoveData::TARGET]==PBTargets::BothSides)
moveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveData.category == 2 && # Status move
[PBTargets::User, PBTargets::BothSides].include?(moveData.target)
score += 60
elsif moveData[MoveData::CATEGORY]!=2 && # Damaging move
moveData[MoveData::TARGET]==PBTargets::NearOther &&
PBTypes.ineffective?(pbCalcTypeMod(moveData[MoveData::TYPE],target,user))
elsif moveData.category != 2 && # Damaging move
moveData.target == PBTargets::NearOther &&
PBTypes.ineffective?(pbCalcTypeMod(moveData.type, target, user))
score += 60
end
end
@@ -2054,7 +2057,8 @@ class PokeBattle_AI
:CHOICEBAND,:CHOICESCARF,:CHOICESPECS])
score += 50
elsif !user.item && target.item
score -= 30 if pbGetMoveData(user.lastMoveUsed,MoveData::FUNCTION_CODE)=="0F2" # Trick/Switcheroo
score -= 30 if user.lastMoveUsed &&
GameData::Move.get(user.lastMoveUsed).function_code == "0F2" # Trick/Switcheroo
end
#---------------------------------------------------------------------------
when "0F3"
@@ -2712,7 +2716,7 @@ class PokeBattle_AI
score -= user.effects[PBEffects::ProtectRate]*40
end
score += 50 if user.turnCount==0
score += 30 if target.effects[PBEffects::TwoTurnAttack]>0
score += 30 if target.effects[PBEffects::TwoTurnAttack]
end
#---------------------------------------------------------------------------
when "14D"
@@ -2924,7 +2928,7 @@ class PokeBattle_AI
score -= user.effects[PBEffects::ProtectRate]*40
end
score += 50 if user.turnCount==0
score += 30 if target.effects[PBEffects::TwoTurnAttack]>0
score += 30 if target.effects[PBEffects::TwoTurnAttack]
score += 20 # Because of possible poisoning
end
#---------------------------------------------------------------------------
@@ -2940,7 +2944,7 @@ class PokeBattle_AI
#---------------------------------------------------------------------------
when "16B"
if skill>=PBTrainerAI.mediumSkill
if target.lastRegularMoveUsed<0 ||
if !target.lastRegularMoveUsed ||
!target.pbHasMove?(target.lastRegularMoveUsed) ||
target.usingMultiTurnAttack?
score -= 90

View File

@@ -287,7 +287,7 @@ class PokeBattle_AI
abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE]
canCheck = true
abilityBlacklist.each do |m|
next if !isConst?(move.id,PBMoves,m)
next if move.id != m
canCheck = false
break
end
@@ -309,7 +309,7 @@ class PokeBattle_AI
abilityBlacklist = [:FILTER,:SOLIDROCK]
canCheck = true
abilityBlacklist.each do |m|
next if !isConst?(move.id,PBMoves,m)
next if move.id != m
canCheck = false
break
end