Change Trainer AI level values to be less random

* 0 = bigger chance to choose a random move
* 1 = smaller chance to choose a random move
* 2 = can switch pokémon to better matchup
This commit is contained in:
JappaWakka 2024-12-25 10:54:03 +01:00
parent d70887c319
commit 3a4535dd57
670 changed files with 231 additions and 231 deletions

View File

@ -5,15 +5,15 @@ Namespace BattleSystem
Public Class TrainerAI Public Class TrainerAI
'Trainer AI Levels:--------------------------------------------------------------------------------------------------------------------- 'Trainer AI Levels:---------------------------------------------------------------------------------------------------------------------
'Normal Trainers: 0-20 (0 being not very smart trainers like Bugcatchers, 20 being Cooltrainers, get higher levels when rematches occur) 'Normal Trainers: 0-1 (0 being not very smart trainers like Bugcatchers, 1 being Cooltrainers, get higher levels when rematches occur)
'(Johto) Gym Leaders: 10-40 (10 for Falkner, 40 for Clair) '(Johto) Gym Leaders: 0-2 (0 for Falkner, 2 for Clair)
'(Kanto) Gym Leaders: All 60 '(Kanto) Gym Leaders: All 2
'Elite 4: 60 'Elite 4: 2
'Lance: 100 'Lance: 2
'Elder Li: 10 'Elder Li: 0
'Rival: 40 'Rival: 2
'Team Rocket Grunts: 5 'Team Rocket Grunts: 0
'Team Rocket Admins: 20 'Team Rocket Admins: 1
Public Shared Function GetAIMove(ByVal BattleScreen As BattleScreen, ByVal OwnStep As Battle.RoundConst) As Battle.RoundConst Public Shared Function GetAIMove(ByVal BattleScreen As BattleScreen, ByVal OwnStep As Battle.RoundConst) As Battle.RoundConst
Dim p As Pokemon = BattleScreen.OppPokemon Dim p As Pokemon = BattleScreen.OppPokemon
@ -123,8 +123,8 @@ Namespace BattleSystem
'-------------------------------------Random move depending on difficulty---------------------------------------------------------' '-------------------------------------Random move depending on difficulty---------------------------------------------------------'
'Only applies if trainer has an AI level below 20: 'Only applies if trainer has an AI level of 0:
If BattleScreen.Trainer.AILevel < 20 Then If BattleScreen.Trainer.AILevel <= 0 Then
Dim AvailableAttacks As List(Of Integer) = New List(Of Integer) Dim AvailableAttacks As List(Of Integer) = New List(Of Integer)
For i = 0 To m.Count - 1 For i = 0 To m.Count - 1
AvailableAttacks.Add(i) AvailableAttacks.Add(i)
@ -158,135 +158,135 @@ Namespace BattleSystem
'-------------------------------------Switching-----------------------------------------------------------------------------------' '-------------------------------------Switching-----------------------------------------------------------------------------------'
'Only applies if trainer has an AI level above or equal 40: 'Only applies if trainer has an AI level above or equal to 2:
'If BattleScreen.Trainer.AILevel >= 40 Then If BattleScreen.Trainer.AILevel >= 2 Then
' If BattleCalculation.CanSwitch(BattleScreen, False) = True Then If BattleCalculation.CanSwitch(BattleScreen, False) = True Then
' If BattleScreen.Trainer.Pokemons.Count > 0 Then If BattleScreen.Trainer.Pokemons.Count > 0 Then
' Dim living As Integer = 0 Dim living As Integer = 0
' For Each cP As Pokemon In BattleScreen.Trainer.Pokemons For Each cP As Pokemon In BattleScreen.Trainer.Pokemons
' If cP.HP > 0 And cP.Status <> Pokemon.StatusProblems.Fainted Then If cP.HP > 0 And cP.Status <> Pokemon.StatusProblems.Fainted Then
' living += 1 living += 1
' End If End If
' Next Next
' If living > 1 Then If living > 1 Then
' 'check for opponent moves: if super effective: 1.5x: 25%, 2x: 50%, 4x: 75%: check for pokemon in party that reacts to every move with less the detected effectiveness 'check for opponent moves: if super effective: 1.5x: 25%, 2x: 50%, 4x: 75%: check for pokemon in party that reacts to every move with less the detected effectiveness
' Dim maxOpponentEff As Single = 0.0F Dim maxOpponentEff As Single = 0.0F
' For Each Attack As BattleSystem.Attack In op.Attacks For Each Attack As BattleSystem.Attack In op.Attacks
' Dim effectiveness As Single = BattleCalculation.CalculateEffectiveness(Attack.GetAttackByID(Attack.ID), BattleScreen, op, p, True) Dim effectiveness As Single = BattleCalculation.CalculateEffectiveness(Attack.GetAttackByID(Attack.ID), BattleScreen, op, p, True)
' If effectiveness > maxOpponentEff Then If effectiveness > maxOpponentEff Then
' maxOpponentEff = effectiveness maxOpponentEff = effectiveness
' End If End If
' Next Next
' If maxOpponentEff > 1.0F Then If maxOpponentEff > 1.0F Then
' Dim chance As Integer = 0 Dim chance As Integer = 0
' Select Case maxOpponentEff Select Case maxOpponentEff
' Case 1.25F Case 1.25F
' chance = 10 chance = 10
' Case 1.5F Case 1.5F
' chance = 25 chance = 25
' Case 2.0F Case 2.0F
' chance = 35 chance = 35
' Case 4.0F Case 4.0F
' chance = 50 chance = 50
' End Select End Select
' If RPercent(chance) = True Then If RPercent(chance) = True Then
' Dim lessTeamPs As New List(Of Integer) Dim lessTeamPs As New List(Of Integer)
' For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1 For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1
' If i <> BattleScreen.OppPokemonIndex Then If i <> BattleScreen.OppPokemonIndex Then
' Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i) Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i)
' If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted Then If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted Then
' Dim alwaysLess As Boolean = True Dim alwaysLess As Boolean = True
' For Each Attack As BattleSystem.Attack In op.Attacks For Each Attack As BattleSystem.Attack In op.Attacks
' Dim effectiveness As Single = BattleCalculation.CalculateEffectiveness(Attack.GetAttackByID(Attack.ID), BattleScreen, op, TeamP, True) Dim effectiveness As Single = BattleCalculation.CalculateEffectiveness(Attack.GetAttackByID(Attack.ID), BattleScreen, op, TeamP, True)
' If effectiveness >= maxOpponentEff Then If effectiveness >= maxOpponentEff Then
' alwaysLess = False alwaysLess = False
' Exit For Exit For
' End If End If
' Next Next
' If alwaysLess = True Then If alwaysLess = True Then
' lessTeamPs.Add(i) lessTeamPs.Add(i)
' End If End If
' End If End If
' End If End If
' Next Next
' If lessTeamPs.Count > 0 Then If lessTeamPs.Count > 0 Then
' Return ProduceOppStep(lessTeamPs(Core.Random.Next(0, lessTeamPs.Count))) Return ProduceOppStep(lessTeamPs(Core.Random.Next(0, lessTeamPs.Count)))
' End If End If
' End If End If
' End If End If
' 'check for own moves: if only 0x: check for other pokemon in party (best fitting) and switch in 'check for own moves: if only 0x: check for other pokemon in party (best fitting) and switch in
' Dim only0 As Boolean = True Dim only0 As Boolean = True
' For Each Attack As BattleSystem.Attack In p.Attacks For Each Attack As BattleSystem.Attack In p.Attacks
' Dim effectiveness As Single = BattleCalculation.CalculateEffectiveness(Attack.GetAttackByID(Attack.ID), BattleScreen, p, op, False) Dim effectiveness As Single = BattleCalculation.CalculateEffectiveness(Attack.GetAttackByID(Attack.ID), BattleScreen, p, op, False)
' If effectiveness <> 0.0F Then If effectiveness <> 0.0F Then
' only0 = False only0 = False
' Exit For Exit For
' End If End If
' Next Next
' If only0 = True Then If only0 = True Then
' Dim switchList As New List(Of Integer) Dim switchList As New List(Of Integer)
' For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1 For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1
' If i <> BattleScreen.OppPokemonIndex Then If i <> BattleScreen.OppPokemonIndex Then
' Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i) Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i)
' If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted Then If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted Then
' switchList.Add(i) switchList.Add(i)
' End If End If
' End If End If
' Next Next
' If switchList.Count > 0 Then If switchList.Count > 0 Then
' Return ProduceOppStep(switchList(Core.Random.Next(0, switchList.Count))) Return ProduceOppStep(switchList(Core.Random.Next(0, switchList.Count)))
' End If End If
' End If End If
' 'own pokemon got cursed: 75% 'own pokemon got cursed: 75%
' If BattleScreen.FieldEffects.OppCurse > 0 Then If BattleScreen.FieldEffects.OppCurse > 0 Then
' If RPercent(75) = True Then If RPercent(75) = True Then
' Dim newSwitchIndex As Integer = 0 Dim newSwitchIndex As Integer = 0
' Dim canSwitchTo As New List(Of Integer) Dim canSwitchTo As New List(Of Integer)
' For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1 For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1
' Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i) Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i)
' If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted And i <> BattleScreen.OppPokemonIndex Then If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted And i <> BattleScreen.OppPokemonIndex Then
' canSwitchTo.Add(i) canSwitchTo.Add(i)
' End If End If
' Next Next
' If canSwitchTo.Count > 0 Then If canSwitchTo.Count > 0 Then
' newSwitchIndex = canSwitchTo(Core.Random.Next(0, canSwitchTo.Count)) newSwitchIndex = canSwitchTo(Core.Random.Next(0, canSwitchTo.Count))
' Return ProduceOppStep(newSwitchIndex) Return ProduceOppStep(newSwitchIndex)
' End If End If
' End If End If
' End If End If
' 'own pokemon got confused: 50% 'own pokemon got confused: 50%
' If p.HasVolatileStatus(Pokemon.VolatileStatus.Confusion) = True Then If p.HasVolatileStatus(Pokemon.VolatileStatus.Confusion) = True Then
' If RPercent(50) = True Then If RPercent(50) = True Then
' Dim newSwitchIndex As Integer = 0 Dim newSwitchIndex As Integer = 0
' Dim canSwitchTo As New List(Of Integer) Dim canSwitchTo As New List(Of Integer)
' For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1 For i = 0 To BattleScreen.Trainer.Pokemons.Count - 1
' Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i) Dim TeamP As Pokemon = BattleScreen.Trainer.Pokemons(i)
' If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted And i <> BattleScreen.OppPokemonIndex Then If TeamP.HP > 0 And TeamP.Status <> Pokemon.StatusProblems.Fainted And i <> BattleScreen.OppPokemonIndex Then
' canSwitchTo.Add(i) canSwitchTo.Add(i)
' End If End If
' Next Next
' If canSwitchTo.Count > 0 Then If canSwitchTo.Count > 0 Then
' newSwitchIndex = canSwitchTo(Core.Random.Next(0, canSwitchTo.Count)) newSwitchIndex = canSwitchTo(Core.Random.Next(0, canSwitchTo.Count))
' Return ProduceOppStep(newSwitchIndex) Return ProduceOppStep(newSwitchIndex)
' End If End If
' End If End If
' End If End If
' End If End If
' End If End If
' End If End If
'End If End If
'-------------------------------------Items---------------------------------------------------------------------------------------' '-------------------------------------Items---------------------------------------------------------------------------------------'

View File

@ -19,6 +19,6 @@ Pokemon5|
Pokemon6| Pokemon6|
Items|14,14,14 Items|14,14,14
Gender|1 Gender|1
AI|60 AI|2
IntroSequence|Orange,Orange IntroSequence|Orange,Orange
IntroType|11 IntroType|11

View File

@ -19,6 +19,6 @@ Pokemon5|
Pokemon6| Pokemon6|
Items|16,16,16 Items|16,16,16
Gender|0 Gender|0
AI|30 AI|1
IntroSequence|Orange,Orange IntroSequence|Orange,Orange
IntroType|11 IntroType|11

View File

@ -18,5 +18,5 @@ Pokemon5|429,48
Pokemon6|601,49 Pokemon6|601,49
Items| Items|
Gender|0 Gender|0
AI|20 AI|1
IntroSequence|Blue,Blue IntroSequence|Blue,Blue

View File

@ -18,5 +18,5 @@ Pokemon5|302,51
Pokemon6|526,54 Pokemon6|526,54
Items| Items|
Gender|0 Gender|0
AI|20 AI|1
IntroSequence|Blue,Blue IntroSequence|Blue,Blue

View File

@ -18,5 +18,5 @@ Pokemon5|606,55
Pokemon6|703,56 Pokemon6|703,56
Items| Items|
Gender|0 Gender|0
AI|20 AI|1
IntroSequence|Blue,Blue IntroSequence|Blue,Blue

View File

@ -18,5 +18,5 @@ Pokemon5|306,61
Pokemon6|94,63 Pokemon6|94,63
Items| Items|
Gender|0 Gender|0
AI|20 AI|1
IntroSequence|Blue,Blue IntroSequence|Blue,Blue

View File

@ -18,5 +18,5 @@ Pokemon5|715,68
Pokemon6|623,70 Pokemon6|623,70
Items| Items|
Gender|0 Gender|0
AI|20 AI|1
IntroSequence|Blue,Blue IntroSequence|Blue,Blue

Some files were not shown because too many files have changed in this diff Show More