- 3
- Posts
- 8
- Years
- Seen Jul 3, 2020
Hello to everyone.
I've been trying to improve pokemon essentials AI on my own. While doing so, I've run into the folowing problem:
What I'm trying to do with this is that the NPC trainer changes his pokemon when he doesn't have a super effective or neutral attack against the pokemon you have on the field. The thing is that after laying entry hazards (the first lines of the script do that, ensure that the pokemon controled by the AI always lays entry hazards before changing) the NPC starts swapping pokemon over and over again, never attacking when he should. As an example, if you (the player) have a Golbat and the NPC (the opponent) has a Joltik, Joltik should use an electric type move but the NPC changes Joltik instead of attacking.
I'm pretty certain that the error is in one of those lines so I'd like for someone to tell me what I've done wrong with the script. I'd also like to keep the script as it is so please tell me how to fix it, not an entirely new one.
Also, on a slightly different note, how can I make a reference to the other pokemon on my team (and on the opponent's team as well)? I mean the ones that are not currently in battle.
Thanks in advance.
I've been trying to improve pokemon essentials AI on my own. While doing so, I've run into the folowing problem:
Spoiler:
if (!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[0].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[1].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[2].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[3].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[0].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[1].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[2].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[3].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[0].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[1].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[2].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[3].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[0].function==0x104) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[1].function==0x104) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[2].function==0x104) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[3].function==0x104)
shouldswitch=false
elsif((@battlers[index].pbOppositeOpposing.pbHasType?(:POISON) &&
@battlers[index].pbOppositeOpposing.pbHasType?(:FLYING) &&
@battlers[index].moves[0].type!=(:STEEL) &&
@battlers[index].moves[0].type!=(:GHOST) &&
@battlers[index].moves[0].type!=(:WATER) &&
@battlers[index].moves[0].type!=(:DRAGON) &&
@battlers[index].moves[0].type!=(:ELECTRIC) &&
@battlers[index].moves[0].type!=(:FIRE) &&
@battlers[index].moves[0].type!=(:ICE) &&
@battlers[index].moves[0].type!=(:PSYQUIC) &&
@battlers[index].moves[0].type!=(:NORMAL) &&
@battlers[index].moves[0].type!=(:DARK) &&
@battlers[index].moves[0].type!=(:FLYING) &&
@battlers[index].moves[0].type!=(:ROCK) &&
@battlers[index].moves[1].type!=(:STEEL) &&
@battlers[index].moves[1].type!=(:GHOST) &&
@battlers[index].moves[1].type!=(:WATER) &&
@battlers[index].moves[1].type!=(:DRAGON) &&
@battlers[index].moves[1].type!=(:ELECTRIC) &&
@battlers[index].moves[1].type!=(:FIRE) &&
@battlers[index].moves[1].type!=(:ICE) &&
@battlers[index].moves[1].type!=(:PSYQUIC) &&
@battlers[index].moves[1].type!=(:NORMAL) &&
@battlers[index].moves[1].type!=(:DARK) &&
@battlers[index].moves[1].type!=(:FLYING) &&
@battlers[index].moves[1].type!=(:ROCK) &&
@battlers[index].moves[2].type!=(:STEEL) &&
@battlers[index].moves[2].type!=(:GHOST) &&
@battlers[index].moves[2].type!=(:WATER) &&
@battlers[index].moves[2].type!=(:DRAGON) &&
@battlers[index].moves[2].type!=(:ELECTRIC) &&
@battlers[index].moves[2].type!=(:FIRE) &&
@battlers[index].moves[2].type!=(:ICE) &&
@battlers[index].moves[2].type!=(:PSYQUIC) &&
@battlers[index].moves[2].type!=(:NORMAL) &&
@battlers[index].moves[2].type!=(:DARK) &&
@battlers[index].moves[2].type!=(:FLYING) &&
@battlers[index].moves[2].type!=(:ROCK) &&
@battlers[index].moves[3].type!=(:STEEL) &&
@battlers[index].moves[3].type!=(:GHOST) &&
@battlers[index].moves[3].type!=(:WATER) &&
@battlers[index].moves[3].type!=(:DRAGON) &&
@battlers[index].moves[3].type!=(:ELECTRIC) &&
@battlers[index].moves[3].type!=(:FIRE) &&
@battlers[index].moves[3].type!=(:ICE) &&
@battlers[index].moves[3].type!=(:PSYQUIC) &&
@battlers[index].moves[3].type!=(:NORMAL) &&
@battlers[index].moves[3].type!=(:DARK) &&
@battlers[index].moves[3].type!=(:FLYING) &&
@battlers[index].moves[3].type!=(:ROCK)))
shouldswitch=true
elsif
(@battlers[index].pbOppositeOpposing.pbHasType?(:POISON) &&
@battlers[index].moves[0].type!=(:STEEL) &&
@battlers[index].moves[0].type!=(:WATER) &&
@battlers[index].moves[0].type!=(:DRAGON) &&
@battlers[index].moves[0].type!=(:GHOST) &&
@battlers[index].moves[0].type!=(:ELECTRIC) &&
@battlers[index].moves[0].type!=(:FIRE) &&
@battlers[index].moves[0].type!=(:ICE) &&
@battlers[index].moves[0].type!=(:NORMAL) &&
@battlers[index].moves[0].type!=(:ROCK) &&
@battlers[index].moves[0].type!=(:PSYQUIC) &&
@battlers[index].moves[0].type!=(:DARK) &&
@battlers[index].moves[0].type!=(:EARTH) &&
@battlers[index].moves[0].type!=(:FLYING) &&
@battlers[index].moves[1].type!=(:STEEL) &&
@battlers[index].moves[1].type!=(:WATER) &&
@battlers[index].moves[1].type!=(:DRAGON) &&
@battlers[index].moves[1].type!=(:GHOST) &&
@battlers[index].moves[1].type!=(:ELECTRIC) &&
@battlers[index].moves[1].type!=(:FIRE) &&
@battlers[index].moves[1].type!=(:ICE) &&
@battlers[index].moves[1].type!=(:NORMAL) &&
@battlers[index].moves[1].type!=(:ROCK) &&
@battlers[index].moves[1].type!=(:PSYQUIC) &&
@battlers[index].moves[1].type!=(:DARK) &&
@battlers[index].moves[1].type!=(:EARTH) &&
@battlers[index].moves[1].type!=(:FLYING) &&
@battlers[index].moves[2].type!=(:STEEL) &&
@battlers[index].moves[2].type!=(:WATER) &&
@battlers[index].moves[2].type!=(:DRAGON) &&
@battlers[index].moves[2].type!=(:GHOST) &&
@battlers[index].moves[2].type!=(:ELECTRIC) &&
@battlers[index].moves[2].type!=(:FIRE) &&
@battlers[index].moves[2].type!=(:ICE) &&
@battlers[index].moves[2].type!=(:NORMAL) &&
@battlers[index].moves[2].type!=(:ROCK) &&
@battlers[index].moves[2].type!=(:PSYQUIC) &&
@battlers[index].moves[2].type!=(:DARK) &&
@battlers[index].moves[2].type!=(:EARTH) &&
@battlers[index].moves[2].type!=(:FLYING) &&
@battlers[index].moves[3].type!=(:STEEL) &&
@battlers[index].moves[3].type!=(:WATER) &&
@battlers[index].moves[3].type!=(:DRAGON) &&
@battlers[index].moves[3].type!=(:GHOST) &&
@battlers[index].moves[3].type!=(:ELECTRIC) &&
@battlers[index].moves[3].type!=(:FIRE) &&
@battlers[index].moves[3].type!=(:ICE) &&
@battlers[index].moves[3].type!=(:NORMAL) &&
@battlers[index].moves[3].type!=(:ROCK) &&
@battlers[index].moves[3].type!=(:PSYQUIC) &&
@battlers[index].moves[3].type!=(:DARK) &&
@battlers[index].moves[3].type!=(:EARTH) &&
@battlers[index].moves[3].type!=(:FLYING))
shouldswitch=true
end
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[1].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[2].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StickyWeb]) && @battlers[index].moves[3].function==0x153) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[0].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[1].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[2].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::StealthRock]) && @battlers[index].moves[3].function==0x105) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[0].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[1].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[2].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::Spikes]) && @battlers[index].moves[3].function==0x103) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[0].function==0x104) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[1].function==0x104) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[2].function==0x104) ||
(!(@battlers[index].pbOppositeOpposing.pbOwnSide.effects[PBEffects::ToxicSpikes]) && @battlers[index].moves[3].function==0x104)
shouldswitch=false
elsif((@battlers[index].pbOppositeOpposing.pbHasType?(:POISON) &&
@battlers[index].pbOppositeOpposing.pbHasType?(:FLYING) &&
@battlers[index].moves[0].type!=(:STEEL) &&
@battlers[index].moves[0].type!=(:GHOST) &&
@battlers[index].moves[0].type!=(:WATER) &&
@battlers[index].moves[0].type!=(:DRAGON) &&
@battlers[index].moves[0].type!=(:ELECTRIC) &&
@battlers[index].moves[0].type!=(:FIRE) &&
@battlers[index].moves[0].type!=(:ICE) &&
@battlers[index].moves[0].type!=(:PSYQUIC) &&
@battlers[index].moves[0].type!=(:NORMAL) &&
@battlers[index].moves[0].type!=(:DARK) &&
@battlers[index].moves[0].type!=(:FLYING) &&
@battlers[index].moves[0].type!=(:ROCK) &&
@battlers[index].moves[1].type!=(:STEEL) &&
@battlers[index].moves[1].type!=(:GHOST) &&
@battlers[index].moves[1].type!=(:WATER) &&
@battlers[index].moves[1].type!=(:DRAGON) &&
@battlers[index].moves[1].type!=(:ELECTRIC) &&
@battlers[index].moves[1].type!=(:FIRE) &&
@battlers[index].moves[1].type!=(:ICE) &&
@battlers[index].moves[1].type!=(:PSYQUIC) &&
@battlers[index].moves[1].type!=(:NORMAL) &&
@battlers[index].moves[1].type!=(:DARK) &&
@battlers[index].moves[1].type!=(:FLYING) &&
@battlers[index].moves[1].type!=(:ROCK) &&
@battlers[index].moves[2].type!=(:STEEL) &&
@battlers[index].moves[2].type!=(:GHOST) &&
@battlers[index].moves[2].type!=(:WATER) &&
@battlers[index].moves[2].type!=(:DRAGON) &&
@battlers[index].moves[2].type!=(:ELECTRIC) &&
@battlers[index].moves[2].type!=(:FIRE) &&
@battlers[index].moves[2].type!=(:ICE) &&
@battlers[index].moves[2].type!=(:PSYQUIC) &&
@battlers[index].moves[2].type!=(:NORMAL) &&
@battlers[index].moves[2].type!=(:DARK) &&
@battlers[index].moves[2].type!=(:FLYING) &&
@battlers[index].moves[2].type!=(:ROCK) &&
@battlers[index].moves[3].type!=(:STEEL) &&
@battlers[index].moves[3].type!=(:GHOST) &&
@battlers[index].moves[3].type!=(:WATER) &&
@battlers[index].moves[3].type!=(:DRAGON) &&
@battlers[index].moves[3].type!=(:ELECTRIC) &&
@battlers[index].moves[3].type!=(:FIRE) &&
@battlers[index].moves[3].type!=(:ICE) &&
@battlers[index].moves[3].type!=(:PSYQUIC) &&
@battlers[index].moves[3].type!=(:NORMAL) &&
@battlers[index].moves[3].type!=(:DARK) &&
@battlers[index].moves[3].type!=(:FLYING) &&
@battlers[index].moves[3].type!=(:ROCK)))
shouldswitch=true
elsif
(@battlers[index].pbOppositeOpposing.pbHasType?(:POISON) &&
@battlers[index].moves[0].type!=(:STEEL) &&
@battlers[index].moves[0].type!=(:WATER) &&
@battlers[index].moves[0].type!=(:DRAGON) &&
@battlers[index].moves[0].type!=(:GHOST) &&
@battlers[index].moves[0].type!=(:ELECTRIC) &&
@battlers[index].moves[0].type!=(:FIRE) &&
@battlers[index].moves[0].type!=(:ICE) &&
@battlers[index].moves[0].type!=(:NORMAL) &&
@battlers[index].moves[0].type!=(:ROCK) &&
@battlers[index].moves[0].type!=(:PSYQUIC) &&
@battlers[index].moves[0].type!=(:DARK) &&
@battlers[index].moves[0].type!=(:EARTH) &&
@battlers[index].moves[0].type!=(:FLYING) &&
@battlers[index].moves[1].type!=(:STEEL) &&
@battlers[index].moves[1].type!=(:WATER) &&
@battlers[index].moves[1].type!=(:DRAGON) &&
@battlers[index].moves[1].type!=(:GHOST) &&
@battlers[index].moves[1].type!=(:ELECTRIC) &&
@battlers[index].moves[1].type!=(:FIRE) &&
@battlers[index].moves[1].type!=(:ICE) &&
@battlers[index].moves[1].type!=(:NORMAL) &&
@battlers[index].moves[1].type!=(:ROCK) &&
@battlers[index].moves[1].type!=(:PSYQUIC) &&
@battlers[index].moves[1].type!=(:DARK) &&
@battlers[index].moves[1].type!=(:EARTH) &&
@battlers[index].moves[1].type!=(:FLYING) &&
@battlers[index].moves[2].type!=(:STEEL) &&
@battlers[index].moves[2].type!=(:WATER) &&
@battlers[index].moves[2].type!=(:DRAGON) &&
@battlers[index].moves[2].type!=(:GHOST) &&
@battlers[index].moves[2].type!=(:ELECTRIC) &&
@battlers[index].moves[2].type!=(:FIRE) &&
@battlers[index].moves[2].type!=(:ICE) &&
@battlers[index].moves[2].type!=(:NORMAL) &&
@battlers[index].moves[2].type!=(:ROCK) &&
@battlers[index].moves[2].type!=(:PSYQUIC) &&
@battlers[index].moves[2].type!=(:DARK) &&
@battlers[index].moves[2].type!=(:EARTH) &&
@battlers[index].moves[2].type!=(:FLYING) &&
@battlers[index].moves[3].type!=(:STEEL) &&
@battlers[index].moves[3].type!=(:WATER) &&
@battlers[index].moves[3].type!=(:DRAGON) &&
@battlers[index].moves[3].type!=(:GHOST) &&
@battlers[index].moves[3].type!=(:ELECTRIC) &&
@battlers[index].moves[3].type!=(:FIRE) &&
@battlers[index].moves[3].type!=(:ICE) &&
@battlers[index].moves[3].type!=(:NORMAL) &&
@battlers[index].moves[3].type!=(:ROCK) &&
@battlers[index].moves[3].type!=(:PSYQUIC) &&
@battlers[index].moves[3].type!=(:DARK) &&
@battlers[index].moves[3].type!=(:EARTH) &&
@battlers[index].moves[3].type!=(:FLYING))
shouldswitch=true
end
What I'm trying to do with this is that the NPC trainer changes his pokemon when he doesn't have a super effective or neutral attack against the pokemon you have on the field. The thing is that after laying entry hazards (the first lines of the script do that, ensure that the pokemon controled by the AI always lays entry hazards before changing) the NPC starts swapping pokemon over and over again, never attacking when he should. As an example, if you (the player) have a Golbat and the NPC (the opponent) has a Joltik, Joltik should use an electric type move but the NPC changes Joltik instead of attacking.
I'm pretty certain that the error is in one of those lines so I'd like for someone to tell me what I've done wrong with the script. I'd also like to keep the script as it is so please tell me how to fix it, not an entirely new one.
Also, on a slightly different note, how can I make a reference to the other pokemon on my team (and on the opponent's team as well)? I mean the ones that are not currently in battle.
Thanks in advance.
Last edited: