Added class GameData::Target

This commit is contained in:
Maruno17
2021-02-24 21:05:04 +00:00
parent 823e7eb8ec
commit 87285a2a1f
20 changed files with 301 additions and 184 deletions

View File

@@ -118,17 +118,17 @@ class PokeBattle_AI
# Trainer Pokémon calculate how much they want to use each of their moves.
def pbRegisterMoveTrainer(user,idxMove,choices,skill)
move = user.moves[idxMove]
targetType = move.pbTarget(user)
if PBTargets.multipleTargets?(targetType)
target_data = move.pbTarget(user)
if target_data.num_targets > 1
# If move affects multiple battlers and you don't choose a particular one
totalScore = 0
@battle.eachBattler do |b|
next if !@battle.pbMoveCanTarget?(user.index,b.index,targetType)
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
score = pbGetMoveScore(move,user,b,skill)
totalScore += ((user.opposes?(b)) ? score : -score)
end
choices.push([idxMove,totalScore,-1]) if totalScore>0
elsif PBTargets.noTargets?(targetType)
elsif target_data.num_targets == 0
# If move has no targets, affects the user, a side or the whole field
score = pbGetMoveScore(move,user,user,skill)
choices.push([idxMove,score,-1]) if score>0
@@ -136,8 +136,8 @@ class PokeBattle_AI
# If move affects one battler and you have to choose which one
scoresAndTargets = []
@battle.eachBattler do |b|
next if !@battle.pbMoveCanTarget?(user.index,b.index,targetType)
next if PBTargets.canChooseFoeTarget?(targetType) && !user.opposes?(b)
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
next if target_data.targets_foe && !user.opposes?(b)
score = pbGetMoveScore(move,user,b,skill)
scoresAndTargets.push([score,b.index]) if score>0
end

View File

@@ -1775,10 +1775,10 @@ class PokeBattle_AI
else
moveData = GameData::Move.get(target.lastRegularMoveUsed)
if moveData.category == 2 && # Status move
[PBTargets::User, PBTargets::BothSides].include?(moveData.target)
[:User, :BothSides].include?(moveData.target)
score += 60
elsif moveData.category != 2 && # Damaging move
moveData.target == PBTargets::NearOther &&
moveData.target == :NearOther &&
PBTypeEffectiveness.ineffective?(pbCalcTypeMod(moveData.type, target, user))
score += 60
end

View File

@@ -3,25 +3,22 @@ class PokeBattle_AI
#
#=============================================================================
def pbTargetsMultiple?(move,user)
numTargets = 0
case move.pbTarget(user)
when PBTargets::AllNearFoes
@battle.eachOtherSideBattler(user) { |b| numTargets += 1 if b.near?(user) }
return numTargets>1
when PBTargets::AllNearOthers
@battle.eachBattler { |b| numTargets += 1 if b.near?(user) }
return numTargets>1
when PBTargets::UserAndAllies
@battle.eachSameSideBattler(user) { |_b| numTargets += 1 }
return numTargets>1
when PBTargets::AllFoes
@battle.eachOtherSideBattler(user) { |_b| numTargets += 1 }
return numTargets>1
when PBTargets::AllBattlers
@battle.eachBattler { |_b| numTargets += 1 }
return numTargets>1
target_data = move.pbTarget(user)
return false if target_data.num_targets <= 1
num_targets = 0
case target_data.id
when :UserAndAllies
@battle.eachSameSideBattler(user) { |_b| num_targets += 1 }
when :AllNearFoes
@battle.eachOtherSideBattler(user) { |b| num_targets += 1 if b.near?(user) }
when :AllFoes
@battle.eachOtherSideBattler(user) { |_b| num_targets += 1 }
when :AllNearOthers
@battle.eachBattler { |b| num_targets += 1 if b.near?(user) }
when :AllBattlers
@battle.eachBattler { |_b| num_targets += 1 }
end
return false
return num_targets > 1
end
#=============================================================================