• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

Generation 8 Project for Essentials v18 and v18.1 (Scripts, PBS and More)

Status
Not open for further replies.
73
Posts
4
Years
    • Online now
    I figured tbh. The bug just keeps getting weirder and weirder too. Now I used Thief before the opponent's Gem was used, and they were still able to use it lol. I think I might have to just start from scratch to fix this.
     
    29
    Posts
    5
    Years
    • Seen Feb 27, 2023
    Hello! I don't know if there is a script out there that includes gen 8 AI move selection. So I decided to tinker a little bit. Be warned that I'm a noob at coding and all I've done was adding lines from other moves to make it work the way they were supposed to....approximately. Please, be free to add/suggest anything. This is not a project, I just had a little free time. There might be errors (almost certainly). There is a ZUD reference in "Lash Out", "D003", ignore it if you don't use ZUD.

    In "AI_Move_EffectScores":

    Spoiler:


    And for "AI_Move_Utilities" (this is not the full script part, I will be sepparating parts with "-----------------------BREAK---------------------------". Just use CRTL + F to find stuff around):

    Spoiler:
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    Hello! I don't know if there is a script out there that includes gen 8 AI move selection. So I decided to tinker a little bit. Be warned that I'm a noob at coding and all I've done was adding lines from other moves to make it work the way they were supposed to....approximately. Please, be free to add/suggest anything. This is not a project, I just had a little free time. There might be errors (almost certainly). There is a ZUD reference in "Lash Out", "D003", ignore it if you don't use ZUD.
    Nice work!

    I noticed a few errors though.
    Eerie Spell is function number 210, and Corrosive Gas is function number 201.
    For Court change, there is nothing more optimal. I would code this like it though:
    Code:
        #---------------------------------------------------------------------------
        when "17A" # Court Change, THIS SERIOUSLY NEEDS SOME OPTIMIZATION
          score += 30 if target.pbOwnSide.effects[PBEffects::AuroraVeil]>0 ||
                         target.pbOwnSide.effects[PBEffects::Reflect]>0 ||
                         target.pbOwnSide.effects[PBEffects::LightScreen]>0 ||
                         target.pbOwnSide.effects[PBEffects::Mist]>0 ||
                         target.pbOwnSide.effects[PBEffects::Safeguard]>0
          score -= 30 if target.pbOwnSide.effects[PBEffects::Spikes]>0 ||
                         target.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 ||
                         target.pbOwnSide.effects[PBEffects::StealthRock] ||
                         target.pbOwnSide.effects[PBEffects::StickyWeb] 
          score -= 30 if user.pbOwnSide.effects[PBEffects::AuroraVeil]>0 ||
                         user.pbOwnSide.effects[PBEffects::Reflect]>0 ||
                         user.pbOwnSide.effects[PBEffects::LightScreen]>0 ||
                         user.pbOwnSide.effects[PBEffects::Mist]>0 ||
                         user.pbOwnSide.effects[PBEffects::Safeguard]>0
          score += 30 if user.pbOwnSide.effects[PBEffects::Spikes]>0 ||
                         user.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 ||
                         user.pbOwnSide.effects[PBEffects::StealthRock] ||
                         user.pbOwnSide.effects[PBEffects::StickyWeb]
    (You don't need to check for the Pledges, I don't think it's useful...)

    # Weather ------------------------------------------>I NEED CONFIRMATION to wether the "Weather Ball" "multipliers[BASE_DMG_MULT] *= 2" actually does the job or if the AI already detects the 50*2=100 damage if there's a weather condition...
    The way it's coded, the AI gets a base power of 50 and not 100. See the function:
    Code:
      #=============================================================================
      # Get a better move's base damage value
      #=============================================================================
      def pbMoveBaseDamage(move,user,target,skill)
        baseDmg = move.baseDamage
        baseDmg = 60 if baseDmg==1
    The line:
    Code:
        baseDmg = move.baseDamage
    gets 50 and not 100.
     
    29
    Posts
    5
    Years
    • Seen Feb 27, 2023
    About the Eerie Spell and Corrosive Gas, one is 210 the other 201 in PBS\moves.txt. But in "Move_Effects_180-1FF" they are PokeBattle_Move_198 and PokeBattle_Move_18F respectivelly. So I changed the values in moves.txt to match each other.

    In Court Change I thought about using conditions too, but then I chose to take every effect individually.
    Ex: opposite side has Reflect and Light Screen, my side has Safeguard. Using conditions it would be +30 for me because enemy has either Reflect or Light Screen (even though it has both) and -30 because I have Safeguard. That would give a score of 0. On the other hand if I score them individually I would have +60 score to get both screens and just -30 to give my Safeguard. Would be beneficial to me if I swapped.
    Agree that 90 score is too much. I'll be editing those scores since some deserve more priority than others, like Aurora Veil being doubly valuable than each screen.
    I'll be editing some other stuff too.

    EDIT:

    Changes to: > "Weather" in "AI_Move_Utilities" - make water moves undesirable under harsh sun (desolate land) and fire moves under heavy rain (primordial sea)
    > Court Change 12-Story block in "AI_Move_EffectScores" - tweaked some scores, increasing relevance to some over others. Ex: Reflect = Light Screen = +30, while Aurora Veil = +60 since it gives both effects at once.
    > Minor update to Scale Shot - The less defense the user has, the less desirable it is.

    Edit 2: OK I hope it's working now

    Writing this for the 3rd time on the notepad because the other 2 times I did, it said I had to reload the page, and all edits were gone :(
    Posting these changes here because it's an edit to Maruno's work, and I'm not mixing them.
    >Added a very basic condition that makes Bide less desirable if the user is in a double battle (while its ally is alive) to prevent users from transforming themselves into punching bags with no chance to retaliate if they get focused.
    >Made Hyper Beams, recoil moves and moves that make you more vulnerable (ex: Close Combat) to check for healing or draining moves first, and if they can be used. If none of those moves are available to use, push strong moves as a last resort.
    >Added exceptions to Pain Split so if the user is faster than the foe and its HP isn't just less than (userHP+foeHP) it won't use Pain Split for a mere HP points. Ex: user 200 HP and enemy 210 HP. (200+210)/2=205 and Pain Split was scored +40 for a mere 5 HP in this case.
    >IMPORTANT: Steel Beam shares its function with Mind Blown ("170"), losing 1/2 of max HP rounding up. However it's registed as the same function has Head Smash and Light of Ruin ("0FC"), which loses 1/2 of damage dealt as HP. Going into PBS\moves.txt finding STEELBEAM and changing from 0FC to 170 should do it.

    Spoiler:
     
    Last edited:
    29
    Posts
    5
    Years
    • Seen Feb 27, 2023
    Hello, I've been playing around with the AI a little more, but I'm too lazy to write changelogs, so I'm sharing 4 .txt files with all the code + edits. I made the AI harder than it was before (I want to believe in that).
    I'm posting this here because it has some gen 8 stuff included. Also, Eerie Spell has 80 BP and 5 PP.

    For short:
    In AI_Switch I always compared pbAIRandom values with the same value so the switch would be 100% successfull with no random factor at all. ex: pbAIRandom(100)<100. Also made them switch immediately instead of waiting 5 turns.
    In AI_Moves, with help, made so only the highest scored move would be used, no gambling. Decision to switch if bad moves: increased score from 20 to 100.
    All damaging moves have a random factor between 0.85 and 1.00, which means an attack will or won't defeat a pokemon by a small margin. I believe that, by doing this:

    "damagePercentage = (realDamage*100.0/target.hp) -10" will force AI to pick a move that will 100% defeat the opponent, Instead of picking something that will most likely defeat it.. Ex: enemy has 50% HP left. AI chooses between Shadow Ball, 48% ~ 53% HP, or Psychic, 75% ~ 80% HP. Since Psychic would kill even at it's lowest damage, it would have the best score, because it would be considered "lethal". However, Shadow Ball would be considered "lethal" too, so it would get the same score as Psychic, and then gamble would happen. By taking 5 points out of the damage calculation, the AI would not see Shadow Ball as a lethal move anymore (43% ~ 48%) and Psychic would be the move to be chosen. I think it works that way lol.

    Increased score for lethal moves so the AI's priority is to defeat the enemy instead of using any other moves that would not defeat it.

    AI_Move_Utilities had some changes and additions while AI_Move_EffectScores had the most.
    It's just to much to count. Had to do some removals to make the AI more unforgiving. Like secondary effects such as "burn" from Flamethrower or -Sp.Def from Psychic. These would have better scores for their secondary effects, which only trigger about 10% of the time. The extra score is just not worth it and it would make these moves surprass other "more damaging" choices. Same with Flinching moves.

    This is for gen 8 project v18.

    Anyways, hope you like it. Always back up the original code in a .txt file before replacing it.

    EDIT:
    Assurance

    Spoiler:
     

    Attachments

    • AI_Moves_Utilities.txt
      29.7 KB · Views: 6
    • AI_Switch.txt
      7.4 KB · Views: 6
    • AI_Move.txt
      12.7 KB · Views: 5
    • AI_Move_EffectScores.txt
      209.6 KB · Views: 5
    Last edited:
    Status
    Not open for further replies.
    Back
    Top