• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Switching Pokemon AI

  • 4
    Posts
    8
    Years
    • Seen Feb 6, 2017
    Hi all!

    I have been working (in PokeBattle_AI) to improve the way that the AI selects the pokemon when has to change to a new one.
    I want AI to select a new pokemon which has a x2 or x4 effectivity move against player's current pokemon and is not a status move, but I am not able to get it.

    I tried so many codes, but this is the last one that I have been testing:

    Code:
    if shouldswitch
        list=[]
        party = pbParty(index)
        opp1 = @battlers[index].pbOpposing1
        for i in 0..party.length-1
         if ((PBTypes.getCombinedEffectiveness(party[i].moves[0].type,opp1.type1,opp1.type2,opp1.effects[PBEffects::Type3])>8) && !(party[i].moves[0].pbIsStatus?))
           list.unshift(i) # put this Pokemon first
           pbRegisterSwitch(index,list[0])
         end
         if ((PBTypes.getCombinedEffectiveness(party[i].moves[1].type,opp1.type1,opp1.type2,opp1.effects[PBEffects::Type3])>8) && !(party[i].moves[1].pbIsStatus?))
           list.unshift(i) # put this Pokemon first
           pbRegisterSwitch(index,list[0])
         end
         if ((PBTypes.getCombinedEffectiveness(party[i].moves[2].type,opp1.type1,opp1.type2,opp1.effects[PBEffects::Type3])>8) && !(party[i].moves[2].pbIsStatus?))
           list.unshift(i) # put this Pokemon first
           pbRegisterSwitch(index,list[0])
         end
         if ((PBTypes.getCombinedEffectiveness(party[i].moves[3].type,opp1.type1,opp1.type2,opp1.effects[PBEffects::Type3])>8) && !(party[i].moves[3].pbIsStatus?))
           list.unshift(i) # put this Pokemon first
           pbRegisterSwitch(index,list[0])
         end
        end
      end

    Which shows this error:

    Spoiler:


    If someone could help me with this code or show me another way to do what I want, I'll really appreciate it.

    Regards!
     
    Maybe this thread can be of use to you.
     
    I read that post, but didn't find anything useful. What Narhok is trying to do is to improve when the AI should switch his pokemon, and what I am trying is to tell the AI what pokemon it should switch.

    Anyways, I appreciate the help. Thank you Telemetius :)
     
    Back
    Top