• 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!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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.

[Discussion] AI discussions

Erh guys, I've started really going deep into improving the AI by myself and I find 2 bugs that renders the damage calc completely useless, here they are:

1- Not as problematic, but this one still ruins the calculations. The damage dealt is being calculated using the attacker pokemon defense/sp.def stats, and not it's opponents as it should, this obviously mess things up.

Code:
    # Get base defense stat
    defense=pbRoughStat(attacker,PBStats::DEFENSE,skill)
    applysandstorm=false
    if type>=0 && move.pbIsSpecial?(type)
      if move.function!=0x122 # Psyshock
        defense=pbRoughStat(attacker,PBStats::SPDEF,skill)
        applysandstorm=true
      end
    end


2- This one ruins everything, and it took me some time to figure out what was causing it. By using the debug console I realized that EVERY basedamage in the damage calculation bit was returning either 0 or 1 while it shouldn't obviously. The problem is here:

Code:
        # Account for accuracy of move
        echo(basedamage.to_s+",")
        accuracy=pbRoughAccuracy(move,attacker,opponent,skill)
        basedamage*=accuracy/100
        echo(basedamage.to_s+",")

So to fix these is pretty simple then yes? You just change 'attacker' to 'opponent' for the first and remove the '/100' from the second? Or does this problem recur throughout the script?
 
Back
Top