- 1,224
- Posts
- 10
- Years
- Omnipresence
- Seen Aug 8, 2023
I'm going to try doing some of the AI things Maruno said still needed to be done.
Check if move will thaw the target
Take additional effects into account:
Opponent more likely to try and set up Light Screens/Reflects early in the battle
Goes in PokeBattle_AI, replacing the appropriate when statements
Reflect
Light Screen
Not sure how well this one works
Slightly prefer status move if having Prankster (goes right after the additional effects snippet from above)
Will add more to this as I go.
Check if move will thaw the target
Spoiler:
Firstly, I noticed the thawing doesn't take into account that the pokemon will not thaw if it has Flash Fire, or Scald thawing the target. Here's a fixed version of that.
For the code for the AI, I added this where Maruno put the if target is frozen TODO
Not sure exactly how the scoring should be, but I figured -60 was appropriate
Both of these use this method (Goes under def canThawUser?)
Code:
# Defrost
if thismove.canThawOpponent? && target.status==PBStatuses::FROZEN &&
!(target.hasWorkingAbility(:FLASHFIRE))
target.pbCureStatus
end
Not sure exactly how the scoring should be, but I figured -60 was appropriate
Code:
# If target is frozen, don't prefer moves that could thaw them # TODO
if opponent.status==PBStatuses::FROZEN
if skill>=PBTrainerAI.mediumSkill
if move.canThawOpponent? && !(opponent.hasWorkingAbility(:FLASHFIRE))
score-=60
end
end
end
Code:
def canThawOpponent? # if move type is Fire (includes Hidden Power Fire?)
if isConst?(@type,PBTypes,:FIRE) || isConst?(@id,PBMoves,:SCALD)
return true
else
return false
end
end
Take additional effects into account:
Spoiler:
Add this right below were I added the #if target is frozen snippet in the AI
Note, this does not take into account whether the additional effect will affect the opponent, but I think it does this elsewhere.
Code:
#Prefer moves with higher chances of additional effect (ignore Sheer Force, occurs elsewhere)
if skill>=PBTrainerAI.mediumSkill && move.addlEffect>0
if !(opponent.hasWorkingAbility(:SHEILDDUST)) && !(attacker.hasWorkingAbility(:SHEERFORCE))
if attacker.hasWorkingAbility(:SERENEGRACE)
score+=(move.addlEffect/2)+20
else
score+=(move.addlEffect/2)
end
end
end
Opponent more likely to try and set up Light Screens/Reflects early in the battle
Goes in PokeBattle_AI, replacing the appropriate when statements
Spoiler:
Reflect
Code:
when 0xA2
if attacker.pbOwnSide.effects[PBEffects::Reflect]>0
score-=90
else
reserves=attacker.pbNonActivePokemonCount
if skill>=PBTrainerAI.highSkill
score+=60 if reserves>2 && attacker.turncount<2
score+=20 if attacker.hasWorkingItem(:LIGHTCLAY)
elsif skill>=PBTrainerAI.mediumSkill
score+=30 if reserves>2 && attacker.turncount<2
score+=20 if attacker.hasWorkingItem(:LIGHTCLAY)
end
end
Code:
when 0xA3
if attacker.pbOwnSide.effects[PBEffects::LightScreen]>0
score-=90
else
reserves=attacker.pbNonActivePokemonCount
if skill>=PBTrainerAI.highSkill
score+=60 if reserves>2 && attacker.turncount<2
score+=20 if attacker.hasWorkingItem(:LIGHTCLAY)
elsif skill>=PBTrainerAI.mediumSkill
score+=30 if reserves>2 && attacker.turncount<2
score+=20 if attacker.hasWorkingItem(:LIGHTCLAY)
end
end
Slightly prefer status move if having Prankster (goes right after the additional effects snippet from above)
Spoiler:
Code:
#mej71
#Prankster
if attacker.hasWorkingAbility(:PRANKSTER) && skill>=PBTrainerAI.highSkill && move.basedamage==0
#check for each type of status move
if (move.function==0x0A && opponent.pbCanBurn?(false)) ||#Burn
(move.function==0x07 && opponent.pbCanParalyze?(false)) || #Paralysis
(move.function==0x06 && opponent.pbCanPoison?(false)) || #Poison
(move.function==0x03 && opponent.pbCanSleep?(false)) || #Sleep
(move.function==0xDC && opponent.effects[PBEffects::LeechSeed]==0) || #Leech Seed
(move.function==0x103 && opponent.pbOwnSide.effects[PBEffects::Spikes]==0) || #Spikes. Likely to put out at least one layers of spikes
(move.function==0x104 && opponent.pbOwnSide.effects[PBEffects::ToxicSpikes]==0) || #Toxic Spikes
(move.function==0x105 && opponent.pbOwnSide.effects[PBEffects::StealthRock]) #Stealth Rocks
score*=1.5 #Likely if it has prankster
end
end
Last edited: